0

FINAL EDIT: I gave up and just did a full reinstallation of WSL2 and everything. Worked great. So if you're somehow dealing with this same problem, a hard reset may be a viable option.

I have already looked at many previous Stack Overflow posts, most notably this one whose second solution is echoed across most other posts on the topic, which is to extend the internal timeout to allot more time for the browser to load pages that take more than the default 60sec.

The Cucumber tests I'm running are small (the one I'm using as a baseline for this is 4 scenarios with 16 steps) and pass virtually instantly when not using Selenium, the pages are mostly static and I just want to be able to see it run+process popups in future tests, so I don't need more load time.

These tests were all working perfectly fine a few months ago (June), but when I reopened the same repo, completely unmodified now I'm unable to run any of the tests with selenium - it doesn't even open the browser anymore when run. As such, I get the feeling it doesn't have to do with my project settings, because none of it has changed. Even so, I've uninstalled the gems and reinstalled them, updated them, all to no avail. I don't know what local system settings/environment variables could have changed during this time, as I work on the app exclusively through WSL2, which I haven't touched since the last time I opened this specific project. Any ideas on this front would be very welcome.

The only configuration I've done for Capybara is setting Capybara.javascript_driver to either :selenium or :selenium_headless between testing sessions in my env.rb file, everything else is running default. My firefox and geckodriver versions are compatible.

Versions:

  • Ubuntu - 20.04.1 LTS
  • Ruby - 2.5.3
  • Firefox - 92.0
  • Geckodriver - 0.29.1
  • xfce4 - 4.14 (ran apt list -a xfce4, as xfce4-about gave me an error: 17:02:48.578: No vendor information found in "/usr/share/xfce4/vendorinfo".

Relevant (?) Gems :

  • selenium-webdriver (4.0.0.rc1)
  • webdriver (0.18.0)
  • cucumber (7.0.0)
  • cucumber-rails (2.4.0)

Please let me know if more information of any type is required, thank you.

EDIT: Relevant Github repos: last working version from a few months ago, most recent development branch as of this post

EDIT 2,4,5: Logs for one Cucumber scenario after setting geckodriver log level to trace:

2021-09-15 17:42:19 DEBUG Selenium Executing Process ["/usr/bin/geckodriver", "--port=4444"]
2021-09-15 17:42:19 DEBUG Selenium polling for socket on ["127.0.0.1", 4444]
1631752939382   geckodriver     INFO    Listening on 127.0.0.1:4444
2021-09-15 17:42:19 WARN Selenium [DEPRECATION] [:browser_options] :options as a parameter for driver initialization is deprecated. Use :capabilities with an Array of value capabilities/options if necessary instead.
2021-09-15 17:42:19 INFO Selenium -> POST session
2021-09-15 17:42:19 INFO Selenium    >>> http://127.0.0.1:4444/session | {"capabilities":{"alwaysMatch":{"browserName":"firefox","moz:firefoxOptions":{"log":{"level":"trace"}}}}}
2021-09-15 17:42:19 DEBUG Selenium      > {"Accept"=>"application/json", "Content-Type"=>"application/json; charset=UTF-8", "User-Agent"=>"selenium/4.0.0.rc1 (ruby linux)", "Content-Length"=>"105"}
1631752939650   mozrunner::runner       INFO    Running command: "/usr/bin/firefox" "--marionette" "-no-remote" "-profile" "/tmp/rust_mozprofileqR2HiM"
1631752939651   geckodriver::marionette DEBUG   Waiting 60s to connect to browser on 127.0.0.1:46793
Net::ReadTimeout (Net::ReadTimeout)
/usr/share/rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/net/protocol.rb:181:in `rbuf_fill'
/usr/share/rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/net/protocol.rb:157:in `readuntil'
/usr/share/rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/net/protocol.rb:167:in `readline'
/usr/share/rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/net/http/response.rb:40:in `read_status_line'
/usr/share/rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/net/http/response.rb:29:in `read_new'
/usr/share/rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/net/http.rb:1494:in `block in transport_request'
/usr/share/rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/net/http.rb:1491:in `catch'
/usr/share/rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/net/http.rb:1491:in `transport_request'
/usr/share/rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/net/http.rb:1464:in `request'
/usr/share/rvm/gems/ruby-2.5.3/gems/selenium-webdriver-4.0.0.rc1/lib/selenium/webdriver/remote/http/default.rb:124:in `response_for'
/usr/share/rvm/gems/ruby-2.5.3/gems/selenium-webdriver-4.0.0.rc1/lib/selenium/webdriver/remote/http/default.rb:77:in `request'
/usr/share/rvm/gems/ruby-2.5.3/gems/selenium-webdriver-4.0.0.rc1/lib/selenium/webdriver/remote/http/common.rb:59:in `call'
/usr/share/rvm/gems/ruby-2.5.3/gems/selenium-webdriver-4.0.0.rc1/lib/selenium/webdriver/remote/bridge.rb:589:in `execute'
/usr/share/rvm/gems/ruby-2.5.3/gems/selenium-webdriver-4.0.0.rc1/lib/selenium/webdriver/remote/bridge.rb:52:in `create_session'
/usr/share/rvm/gems/ruby-2.5.3/gems/selenium-webdriver-4.0.0.rc1/lib/selenium/webdriver/common/driver.rb:338:in `create_bridge'
/usr/share/rvm/gems/ruby-2.5.3/gems/selenium-webdriver-4.0.0.rc1/lib/selenium/webdriver/common/driver.rb:73:in `initialize'
/usr/share/rvm/gems/ruby-2.5.3/gems/selenium-webdriver-4.0.0.rc1/lib/selenium/webdriver/common/driver.rb:53:in `new'
/usr/share/rvm/gems/ruby-2.5.3/gems/selenium-webdriver-4.0.0.rc1/lib/selenium/webdriver/common/driver.rb:53:in `for'
/usr/share/rvm/gems/ruby-2.5.3/gems/selenium-webdriver-4.0.0.rc1/lib/selenium/webdriver.rb:87:in `for'
/home/nacho/Github/cs370/features/support/env.rb:18:in `<top (required)>'
/usr/share/rvm/gems/ruby-2.5.3/gems/cucumber-7.0.0/lib/cucumber/glue/registry_and_more.rb:121:in `require'
/usr/share/rvm/gems/ruby-2.5.3/gems/cucumber-7.0.0/lib/cucumber/glue/registry_and_more.rb:121:in `load_code_file'
/usr/share/rvm/gems/ruby-2.5.3/gems/cucumber-7.0.0/lib/cucumber/runtime/support_code.rb:142:in `load_file'
/usr/share/rvm/gems/ruby-2.5.3/gems/cucumber-7.0.0/lib/cucumber/runtime/support_code.rb:81:in `block in load_files!'
/usr/share/rvm/gems/ruby-2.5.3/gems/cucumber-7.0.0/lib/cucumber/runtime/support_code.rb:80:in `each'
/usr/share/rvm/gems/ruby-2.5.3/gems/cucumber-7.0.0/lib/cucumber/runtime/support_code.rb:80:in `load_files!'
/usr/share/rvm/gems/ruby-2.5.3/gems/cucumber-7.0.0/lib/cucumber/runtime.rb:260:in `load_step_definitions'
/usr/share/rvm/gems/ruby-2.5.3/gems/cucumber-7.0.0/lib/cucumber/runtime.rb:72:in `run!'
/usr/share/rvm/gems/ruby-2.5.3/gems/cucumber-7.0.0/lib/cucumber/cli/main.rb:29:in `execute!'
/usr/share/rvm/gems/ruby-2.5.3/gems/cucumber-7.0.0/bin/cucumber:9:in `<top (required)>'
/usr/share/rvm/gems/ruby-2.5.3/bin/cucumber:23:in `load'
/usr/share/rvm/gems/ruby-2.5.3/bin/cucumber:23:in `<main>'
/usr/share/rvm/gems/ruby-2.5.3/bin/ruby_executable_hooks:24:in `eval'
/usr/share/rvm/gems/ruby-2.5.3/bin/ruby_executable_hooks:24:in `<main>'

EDIT 3: I've been poring through the log and googling various terms/lines, I'm not really coming up with too much that I know how to work with, though. A few things I've done:

  • Connect to 127.0.0.1:35213 and its variants, as it changes each time I run the tests, and saw a working version of my app
  • Tried to connect to the various sockets it was listening to like 127.0.0.1:4487 and 127.0.0.1:4487/session which stays the same between tests, but it would either a) not load or b) return a blank page with the text HTTP method not allowed in plain HTML
  • Read Timeouts are almost always network related. Try turning on logging to see if there is more info you can get: `Selenium::WebDriver.logger.level = :debug`. And webdriver is an alternative implementation to selenium-webdriver so you shouldn't need both. – titusfortner Sep 15 '21 at 20:34
  • @titusfortner Thanks for the information! Set it to debug, added log to main post – Austin Wangyu Sep 15 '21 at 20:42
  • Yeah, you're not even getting a session from the driver. I'm guessing something is happening after the mozrunner line and it isn't getting reported. Try turning on geckodriver logging by adding this to capabilities: `{"moz:firefoxOptions": {"log": {"level": "trace"}}}` – titusfortner Sep 16 '21 at 00:02
  • For posterity - [Selenium Ruby client has helpers to do this](https://firefox-source-docs.mozilla.org/testing/geckodriver/TraceLogs.html#ruby) ```Selenium::WebDriver.logger.level = :debug opts = Selenium::WebDriver::Firefox::Options.new(log_level: :trace) driver = Selenium::WebDriver.for :firefox, options: opts``` Adding the output to the main post now! – Austin Wangyu Sep 16 '21 at 00:15
  • It doesn't look like it's outputting any trace logs, I'm not sure how to tell if it's working or not but it also no longer even runs the rest of the tests, it just errors out and exits. I tried some of the other options in the link above for setting trace logs, namely by running `geckodriver --log trace` and `geckodriver --v` in command line, but I'm getting an error `geckodriver: error: Address already in use (os error 98)`, but I run `lsof -i` on the port associated with geckodriver (`4444`) and it only returns geckodriver. – Austin Wangyu Sep 16 '21 at 00:31
  • I restarted my computer and ran it again, got a few new lines in the logs. Changed main post I didn't finish setting up my .bashrc environment variables, logs are all the same as before – Austin Wangyu Sep 16 '21 at 00:39
  • Well, the next line after that is *supposed to be: `Marionette INFO Marionette enabled`. Geckodriver should be giving some kind of error and it isn't. What is the exact code you are using to start the driver? You might need to file a bug report at https://github.com/mozilla/geckodriver/issues – titusfortner Sep 16 '21 at 02:07
  • I'm running `cucumber features/admin/admin_authentication.feature` to run the test named as such; I don't ever run geckodriver on its own via the command line, if that's relevant here? Do you have any ideas as to what local system settings/environment variables might play a role in this? I'm hesitant to file a bug report in that I feel like it's an issue with my setup. – Austin Wangyu Sep 16 '21 at 02:14
  • I'm interested in what code is in your hooks or env files that initializes the driver. Is it anything more than what you posted above? (`Selenium::WebDriver::Firefox::Options.new(log_level: :trace)`) Selenium starts geckodriver automatically. The reason I suggest filing a bug is that even if it is somehow an issue with your setup, geckodriver in trace mode should be telling you more than it is, and someone at Mozilla should know why. – titusfortner Sep 16 '21 at 02:27
  • I did a quick search for all instances of Selenium in my project and this four-line excerpt is the only instance of it in my current env.rb: `Capybara.javascript_driver = :selenium_headless` `Selenium::WebDriver.logger.level = :debug` `opts = Selenium::WebDriver::Firefox::Options.new(log_level: :trace)` `driver = Selenium::WebDriver.for :firefox, options: opts` I also have my repositories linked above, in case I'm misunderstanding or not searching for the correct terms, I inherited a lot of backend for this codebase, including the whole test suite setup. I'll file a bug report now. – Austin Wangyu Sep 16 '21 at 02:37

2 Answers2

0

not sure what the webdriver 0.18.0 gem is? But if you can push up a repo that we can pull down and triage, I'd be happy to help.

From your original post there's also nothing reproducible. So let us know once you have a github link. I'd wager the issue is your project / pc settings

Luke Hill
  • 460
  • 2
  • 10
  • Hi Luke, thanks for the reply; [here's a link to the repo for the last working version from a few months ago](https://github.com/saasbook/cs370), [here's a link to my repo+branch with recent changes to the app itself](https://github.com/austin-wangyu/cs370/tree/178342739-create-user-model-overhaul). I made the lazy choice to not follow BDD though, so the tests are all due to fail in the more recent branch. The tests should all pass in the first link, though. – Austin Wangyu Sep 15 '21 at 19:47
  • I also inherited some amount of legacy code that I slowly tore out over time, and so I'm also not sure what the [webdriver 0.18.0 gem](https://rubygems.org/gems/webdriver/versions/0.18.0) is either, but since everything worked fine before I didn't want to accidentally cause a problem by removing some small dependency. Once/if I can get testing working again I'll try removing it and see what breaks, I suppose? – Austin Wangyu Sep 15 '21 at 19:54
  • That gem looks quite suspect. I'd be VERY careful of using it. FYI That is not selenium-webdriver but something maintained by someone else, with no affiliation to selenium in any way – Luke Hill Sep 22 '21 at 11:03
0

I gave up trying to fix anything and just uninstalled Ubuntu and reinstalled it, went through the full setup process again but omitted xfce4 because I realized I didn't need it for my purposes. Fresh start worked out, wish I'd done this three hours in instead of four days in. Live and learn, I suppose.