Getting timeouts when I try to evaluate during a breakpoint in Rubymine


#1

Do other people use Appium/Android from Rubymine. I’ve noticed that when I try to run commands during a breakpoint from the Evaluate popup it times out. But if I continue the same methods on the appium driver work. Is there something I’m missing? I was able to do this before I converted from

driver = Selenium::WebDriver.for(:remote, :desired_capabilities => capabilities, :url => server_url)

to

appium       = Appium::Driver.new(caps: capabilities)
driver       = appium.start_driver

Stacktrace using Appium 1.3.4:

"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/common/element.rb:54:in `click'"
"/Users/blavelle/git/HAMobile-Test/lib/hamvc/configuration.rb:141:in `new_driver'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/debase-0.0.9/lib/debase/context.rb:37:in `at_line'"
"/Users/blavelle/git/HAMobile-Test/lib/hamvc/configuration.rb:141:in `new_driver'"
"/Users/blavelle/git/HAMobile-Test/lib/hamvc/configuration.rb:15:in `driver'"
"/Users/blavelle/git/HAMobile-Test/lib/hamvc/view.rb:8:in `initialize'"
"/Users/blavelle/git/HAMobile-Test/lib/mobile/navigation.rb:8:in `new'"
"/Users/blavelle/git/HAMobile-Test/lib/mobile/navigation.rb:8:in `initialize'"
"/Users/blavelle/git/HAMobile-Test/spec/client/calendar_spec.rb:6:in `new'"
"/Users/blavelle/git/HAMobile-Test/spec/client/calendar_spec.rb:6:in `block (2 levels) in <top (required)>'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/hooks.rb:350:in `instance_exec'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/hooks.rb:350:in `run'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/hooks.rb:459:in `run'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/hooks.rb:500:in `run'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/example_group.rb:426:in `block in run_before_context_hooks'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/memoized_helpers.rb:141:in `block in isolate_for_context_hook'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/memoized_helpers.rb:137:in `instance_exec'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/memoized_helpers.rb:137:in `isolate_for_context_hook'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/example_group.rb:425:in `run_before_context_hooks'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/example_group.rb:452:in `run'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:111:in `block (2 levels) in run_specs'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:111:in `map'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:111:in `block in run_specs'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/reporter.rb:53:in `report'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:107:in `run_specs'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:85:in `run'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:69:in `run'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:37:in `invoke'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/exe/rspec:4:in `<top (required)>'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/bin/rspec:23:in `load'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/bin/rspec:23:in `<top (required)>'"

#2

It’s probably a difference in the timeouts. Check the implicit wait value (ex: set_wait 0).

If that doesn’t work, create a reduced test case and file it on github so the problem is addressed. There’s too much custom code there to isolate the problem to appium.


#3

Shouldn’t it be

Appium::Driver.new(capabilities) ?

#4

It needs the caps:


#5

My bad, I forgot that I am passing capabilities like that:

capabilities = {caps:
                    {:deviceName => 'Nexus 4',
                     ...
                     ...
                    }
}

#6

I’m thinking this doesn’t have anything to do with the set_wait, it was 30 but I changed it to 0, the timeout I’m getting is 10 seconds and I even tried to set it in the minimal program using my app.

require 'appium_lib'

capabilities = {
    platformName:      :android,
    deviceName:        '',
    androidPackage:    'com.vacationrentals.homeaway.stage',
    appActivity:       'com.vacationrentals.homeaway.activities.SplashActivity',
    newCommandTimeout: 0,
}

appium = Appium::Driver.new(caps: capabilities)
driver = appium.start_driver
driver.find_element(:name, 'welcome_travelerButtonTitle').click
driver.find_element(:name, 'shared_search').click
driver.navigate.back
#breakpoint below this line
driver.find_element(:name, 'shared_favorites').click
driver.navigate.back

When the break point hits I get the 10 second timeout trying commands before or after the breakpoint. When I resume the program the driver methods work. I’m going to look deeper to see if I can find the problem.

Here is the stack trace:

"/Users/blavelle/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/timeout.rb:70:in `join'"
"/Users/blavelle/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/timeout.rb:70:in `timeout'"
"/Users/blavelle/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/net/http.rb:877:in `connect'"
"/Users/blavelle/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/net/http.rb:862:in `do_start'"
"/Users/blavelle/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/net/http.rb:851:in `start'"
"/Users/blavelle/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/net/http.rb:1367:in `request'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/http/default.rb:83:in `response_for'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/http/default.rb:39:in `request'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/http/common.rb:40:in `call'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/bridge.rb:640:in `raw_execute'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/bridge.rb:618:in `execute'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/bridge.rb:586:in `find_element_by'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/common/search_context.rb:42:in `find_element'"
"/Users/blavelle/git/HAMobile-Test/laboratory/android_appium.rb:17:in `<top (required)>'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/debase-0.0.9/lib/debase/context.rb:37:in `at_line'"
"/Users/blavelle/git/HAMobile-Test/laboratory/android_appium.rb:17:in `<top (required)>'"

If I get the driver this way:

driver = Selenium::WebDriver.for(:remote, :desired_capabilities => capabilities, :url => 'http://127.0.0.1:4723/wd/hub')

Then I can evaluate code at a breakpoint.


#7

If you compare the server logs for driver = Selenium::WebDriver.for vs Appium::Driver.new, maybe there is some difference in the desired capabilities being sent to the server.


#8

I ran the xunit android example code. I found an element, then stopped on a breakpoint on line 34. The session stayed open and didn’t timeout after 10 seconds. I tested with ruby 2.1.5p273 and the latest RubyMine.

There’s something in your code causing the problem. Try the sample code to see if you get a different result. The sample works for me. Also note that this sample doesn’t pass, that’s a different issue.


#9

I’ve been meaning to reproduce this with the reference app but I just got this to happen while debugging one of my rest tests so it has nothing to do with Appium. The 1.3.1 doesn’t trigger this bug but 1.3.4 does. Here is the stack trace for a test using restclient:

"/Users/blavelle/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/timeout.rb:70:in `join'"
"/Users/blavelle/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/timeout.rb:70:in `timeout'"
"/Users/blavelle/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/net/http.rb:877:in `connect'"
"/Users/blavelle/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/net/http.rb:862:in `do_start'"
"/Users/blavelle/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/net/http.rb:851:in `start'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rest-client-1.7.2/lib/restclient/request.rb:413:in `transmit'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rest-client-1.7.2/lib/restclient/request.rb:176:in `execute'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rest-client-1.7.2/lib/restclient/request.rb:41:in `execute'"
"/Users/blavelle/git/HAMobile-Test/lib/hamvc/rest_controller.rb:47:in `request'"
"/Users/blavelle/git/HAMobile-Test/lib/hamvc/rest_controller.rb:75:in `get'"
"/Users/blavelle/git/HAMobile-Test/lib/modash/owner_inbox_quote_template_controller.rb:13:in `get'"
"/Users/blavelle/git/HAMobile-Test/spec/modash/owner_inbox_quote_spec.rb:106:in `block (3 levels) in <top (required)>'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/memoized_helpers.rb:242:in `block (2 levels) in let'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/memoized_helpers.rb:242:in `fetch'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/memoized_helpers.rb:242:in `block in let'"
"/Users/blavelle/git/HAMobile-Test/spec/modash/owner_inbox_quote_spec.rb:107:in `block (3 levels) in <top (required)>'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/debase-0.0.9/lib/debase/context.rb:37:in `at_line'"
"/Users/blavelle/git/HAMobile-Test/spec/modash/owner_inbox_quote_spec.rb:107:in `block (3 levels) in <top (required)>'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/example.rb:152:in `instance_exec'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/example.rb:152:in `block in run'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/example.rb:329:in `with_around_example_hooks'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/example.rb:149:in `run'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/example_group.rb:490:in `block in run_examples'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/example_group.rb:486:in `map'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/example_group.rb:486:in `run_examples'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/example_group.rb:453:in `run'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/example_group.rb:454:in `block in run'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/example_group.rb:454:in `map'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/example_group.rb:454:in `run'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:111:in `block (2 levels) in run_specs'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:111:in `map'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:111:in `block in run_specs'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/reporter.rb:53:in `report'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:107:in `run_specs'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:85:in `run'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:69:in `run'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:37:in `invoke'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.1.7/exe/rspec:4:in `<top (required)>'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/bin/rspec:23:in `load'"
"/Users/blavelle/.rvm/gems/ruby-2.0.0-p451/bin/rspec:23:in `<top (required)>'"

#10

Unfortunately the only way I can see this getting fixed is if the appium developers have a way to reliably reproduce the problem. My guess is it’s something in your code and not an appium bug.

Edit: I missed the part about this not being appium related. Usually the correct fix for time out problems is to use a client side wait (a technique not specific to appium).


#11

@brentlavelle RubyMine is having quite a few bugs , this is one of them. Frankly as compared to Eclipse , RubyMine needs to fix lots of bugs and do improvements. ( have shifted from Java to Ruby recently )

You can file support ticket with RubyMine team with sample code you’re having trouble with.

Regards,
Vikram


#12

A work around would be to use Pry for debugging instead of the RubyMine debugger.


#13

I was never able to get this working on my machine again so I use pry now. It is better than the debugger in some ways and not as nice in others. I now run tests in a Terminal pane instead of the run and run in context. The reason is that pry uses stdin and stdout. The first time you forget this your program will apparently hang when it hits the first pry. Good luck. I need to upgrade to yosemite soon, I hope that will fix this problem if not I need to start uninstalling things and reinstalling.

This is not an Appium issue as it happens when I use Calabash and API tests as well.


#14

Here the workaround if you still want to use Rubymine and debug.
In the appium_lib>lib>appium_lib>driver.rb, method start_driver, change the open_timeout value to 0:

    # Creates a new global driver and quits the old one if it exists.
    #
    # @return [Selenium::WebDriver] the new global driver

def start_driver
  # open_timeout and read_timeout are explicit wait.
  @http_client ||= Selenium::WebDriver::Remote::Http::Default.new(open_timeout: 0, read_timeout: 999_999)

Maybe start_driver should accept parameters to change this open_timeout and read_timeout values ?


#15

Thanks alot.
I have changed the config of start driver method and it worked for me.