Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: update how Selenium is configured #457

Closed
wants to merge 1 commit into from
Closed

test: update how Selenium is configured #457

wants to merge 1 commit into from

Conversation

G-Rath
Copy link
Contributor

@G-Rath G-Rath commented Apr 4, 2024

Summary

This updates how Selenium is configured so that the dummy specs can be run locally in more environments such as Ubuntu on WSLv2.

Pull Request checklist

Remove this line after checking all the items here. If the item does not apply to the PR, both check it out and wrap it by ~.

  • Add/update test to cover these changes
  • Update documentation
  • Update CHANGELOG file

Other Information

I think this is just the result of the dummy project being generated a long time ago and so this is effectively just updating the config based on changes that have happened over the years - specifically this was based on the config we generate in our rails-template.

Before this is landed someone should try this locally to ensure this doesn't just "work on my machine" - until then I'll mark this as a draft.

Capybara.register_server(Capybara.javascript_driver) do |app, port|
require "rack/handler/puma"
Rack::Handler::Puma.run(app, Port: port)
end

config.before(:each, type: :system, js: true) do
driven_by driver
Copy link
Collaborator

@tomdracz tomdracz Apr 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@G-Rath Tested this locally (Mac) and it's failing 😅 Pretty sure it's that line here. After removals we are ending with nil so defaulting back to whatever driver is default 🤔 With the addition as suggestion below it does seem to work as expected though

Suggested change
driven_by driver
driven_by :selenium_chrome

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ironically I'm pretty sure that's the most problematic:

2024-04-06 07:54:25 INFO Selenium [:logger_info] Details on how to use and modify Selenium logger:
  https://selenium.dev/documentation/webdriver/troubleshooting/logging

2024-04-06 07:54:25 WARN Selenium [:selenium_manager] The version of chrome cannot be detected. Trying with latest driver version
2024-04-06 07:54:26 WARN Selenium [:selenium_manager] The version of chrome cannot be detected. Trying with latest driver version
F2024-04-06 07:54:26 WARN Selenium [:selenium_manager] The version of chrome cannot be detected. Trying with latest driver version
2024-04-06 07:54:27 WARN Selenium [:selenium_manager] The version of chrome cannot be detected. Trying with latest driver version
F

Failures:

  1) hello_world loads correct view
     Got 0 failures and 2 other errors:

     1.1) Failure/Error: visit "/hello_world"

          Selenium::WebDriver::Error::UnknownError:
            unknown error: cannot find Chrome binary

I'll do some more digging - for context, WSL (Windows Subsystem for Linux) runs an integrated terminal-based VM within Windows which nowdays ships with WSLg by default so you can run GUIs natively alongside Windows apps; I've been able to run both headless and headful browser based tests with RSpec without major issue though I already know it doesn't work in all cases but at this point I think that's more a configuration thing then WSL itself.

i.e. with apps generated with our rails-template I can run standard heavy tests, but our lighthouse accessibility and performance based tests which uses lighthouse-matchers fail

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. On my end without this change, the JS specs were falling as there was nothing executing JS. If they passed on your end, then I wonder what is running that 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok apparently I've just been silly - updating selenium-webdriver was the real fix, because they introduced the webdriver autofinding logic in ~4.15+ and I was using 4.10 🤷

@G-Rath G-Rath closed this Apr 6, 2024
@G-Rath G-Rath deleted the update-dummy-setup branch April 6, 2024 18:57
@ahangarha
Copy link
Contributor

This issue of version mismatch is really annoying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants