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

Use Selenium with headless Chrome in system tests #106

Merged
merged 4 commits into from
Nov 4, 2020
Merged

Use Selenium with headless Chrome in system tests #106

merged 4 commits into from
Nov 4, 2020

Conversation

volmer
Copy link
Contributor

@volmer volmer commented Oct 27, 2020

We now have a significant system test suite that is struggling with Rack test alone. With the addition of rapid-changing states and auto-refresh, we need to use a real-life browser such as Chrome to assert expectations properly with a closer-to-real test scenarios.

In an additional commit I am also improving assertions around system tests, such as ensuring that the timestamp used is different than the one used in our fixtures, as well as ensuring that there are no error information displayed when not expected.

A great benefit of using a real browser is that now we will have page screenshots when a test fails both locally and on CI. If a system test fails on GitHub you can simply download the zip file with the run artifacts and check the images.

Fixes #107

Copy link
Contributor

@adrianna-chang-shopify adrianna-chang-shopify left a comment

Choose a reason for hiding this comment

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

This is cool! ❤️

A couple questions (stemming from my general lack of knowledge re: Selenium / webdrivers).

I've noticed that running bundle exec rake test produces the following warning:

➜  maintenance_tasks git:(chrome) ✗ be rake test
/Users/adriannachang/.gem/ruby/2.6.3/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324: warning: /Users/adriannachang/.gem/ruby/2.6.3/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324: warning: loading in progress, circular require considered harmful - /Users/adriannachang/.gem/ruby/2.6.3/gems/webdrivers-4.4.1/lib/webdrivers.rb

Is this something we care about? Or is it beyond our control?

.github/workflows/ruby.yml Show resolved Hide resolved
@volmer
Copy link
Contributor Author

volmer commented Oct 30, 2020

Fixed the warning!

Copy link
Member

@etiennebarrie etiennebarrie left a comment

Choose a reason for hiding this comment

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

Can we use the config mentioned here to make puma quiet?
https://github.com/teamcapybara/capybara/blob/master/README.md#setup

Also puma raises a warning when it boots that way.

@etiennebarrie
Copy link
Member

Yeah the warning comes from puma/puma#2455 and teamcapybara/capybara#2413 but I believe we could avoid it by manually setting the environment, but it sucks a bit.

@etiennebarrie
Copy link
Member

Apparently there's a way to setup the capybara server directly, even though it's not documented: https://github.com/rails/rails/blob/v6.0.3.4/actionpack/lib/action_dispatch/system_testing/server.rb#L7

Regarding the warning, it will raise when using bundle exec rake, because the test_helper is loaded and sets Warning.warn. Not sure what changes when we're just using bundle exec rails app:test:system, but Capybara doesn't seem to load it (which would make sense, not loading the test_helper when running the server.

Copy link
Member

@etiennebarrie etiennebarrie left a comment

Choose a reason for hiding this comment

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

The deprecation warning from Capybara has been hidden by the fact that the configuration from #125 doesn't create a new process with the -w flag, and Ruby 2.7.2 has turned off deprecation warnings by default without that. If we had a Warning[:deprecated] = true in test_helper we'll get it back. I can look at this later though.

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.

Switch system tests to use headless chrome
3 participants