0

I'm getting a timeout error when waiting for table element to appear containing results of a query executed in the previous steps of a cucumber test scenario. The strange thing about this error is that it only happens the first time the test is run (within the debian Linux command shell) but then the will succeed (ie the wait_until_present call does NOT timeout) for each subsequent test run after that. If I do not re-run the test for 30 minutes and then try to run it again within the same command shell the issue is reproduced but then each run after that will succeed. See below cucumber test script results as below cucumber test script

Below is the code that runs the And I click on the Query button step

def click_query_button
  @browser.button(:text => "Query").click
  @browser.div(:class => "xtb-text").wait_until_present
  begin
    @browser.table(:class => "x-grid3-row-table").wait_until_present
  rescue
    @browser.screenshot.save 'query_button_result_table_fail.png'
    puts "Results table exists?"
    puts @browser.table(:class => "x-grid3-row-table").exists?
    puts "WARNING: waited 30 seconds without the results table being loaded, taking a screenshot and re-running the scenario as it should appear on the second attempt"
    puts "Refer to MAP-841 for further details"
end

I tried increasing the wait time out to 60 seconds which did not make a difference. Also tried adding the @browser.table(:class => "x-grid3-row-table").exists? call and it was apparent that the table element did not exist in the DOM and was not going to load regardless of how long I set the timeout. I also tried re-running the @browser.button(:text => "Query").click step a second time within the same test scenario and it did not make a difference.

I also tried reproducing the error manually on the application under test using a windows 7 machine and running a Chrome browser v59.0.3071.86 (simulating what users actually have) but could not reproduce it.

My environment is

  • Debian Linux v7.1
  • ruby 2.0.0p643 (2015-02-25 revision 49749)
  • watir v2.4.8
  • watir-webdriver (0.9.1)
  • selenium-webdriver (2.48.1)
  • Chrome Browser v45.0.2454.85
  • Using xvfb to render the above browser in a headless linux environment
  • ChromeDriver 2.20.353124

Would greatly appreciate any ideas for further diagnosis that I could apply.

Costa
  • 45
  • 8
  • what version of watir? Did the screenshot show that the element was there even though the code said it was not? – titusfortner Jul 14 '17 at 03:57
  • watir v2.4.8. The screenshot showed that the element was NOT there and hence was consistent with what the code was reporting. – Costa Jul 14 '17 at 05:05
  • Was "LTE%" properly entered? Perhaps there was a race condition with the clicking after the text entering? Also `watir-webdriver` has been deprecated, just use `watir`; the latest version as of this morning is 6.4.1. – titusfortner Jul 14 '17 at 06:05
  • I confirmed that "LTE%" was being entered correctly prior to when the query button is being clicked. I also added a 4 second sleep between the steps but still the same result. Good idea though thanks for the suggestion @titusfortner. I will try your other suggestion and upgrade to watir v6.4.1 – Costa Jul 17 '17 at 07:15
  • I upgraded all my gems and installed watir v6.4.3. In my _hooks.rb_ file I commented out 'require "watir-webdriver"' and added 'require "watir"'. When I run the test I get the error in the below comment. Is there something else I need to do use _watir_ instead of _watir-webdriver_? – Costa Jul 20 '17 at 23:21
  • Here are the first few lines of the error mentioned above `costa@costadev:~/gspt/AcceptenceTest/gspt$ cucumber features/queries.feature /home/costa/.rvm/gems/ruby-2.0.0-p643/gems/watir-6.4.3/lib/watir/wait.rb:8: warning: already initialized constant Watir::Wait::INTERVAL /home/costa/.rvm/gems/ruby-2.0.0-p643/gems/watir-webdriver-0.9.9/lib/watir-webdriver/wait.rb:9: warning: previous definition of INTERVAL was here` – Costa Jul 20 '17 at 23:28
  • Next few lines of the error: `/home/costa/.rvm/gems/ruby-2.0.0-p643/gems/watir-6.4.3/lib/watir/atoms.rb:4: warning: already initialized constant Watir::Atoms::ATOMS /home/costa/.rvm/gems/ruby-2.0.0-p643/gems/watir-webdriver-0.9.9/lib/watir-webdriver/atoms.rb:4: warning: previous definition of ATOMS was here can't modify frozen Hash (RuntimeError)` – Costa Jul 20 '17 at 23:32
  • If you'll notice the stack trace, the errors are coming from `watir-webdriver`, which means it is still getting required somewhere in your code. – titusfortner Jul 21 '17 at 00:01
  • Found it. Test now runs but unfortunately I'm still getting the same behaviour. That is the timeout on the first attempt but then the test passes on the second. I can't upgrade my browser or chromedriver version as the latest version of google chrome does not support Debian Wheezy anymore. Seems like my options are running out :-( – Costa Jul 21 '17 at 00:33
  • Honestly this sounds like a problem with the website you are testing not with the code. If the code is properly entering text and then clicking the button, but the result you expect isn't showing up... – titusfortner Jul 21 '17 at 00:43
  • Yes I was starting to think the same, ie that this must be an issue with the application under test. However I can't reproduce it manually as a user. It only manifests itself through the test automation. Having said that the environment I'm using to test manually isn't the same as it's windows 7 and using a much later chrome browser v59. – Costa Jul 21 '17 at 01:23

0 Answers0