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

[UPDATED] Implement a way to add browser capabilities #35081

Merged
merged 3 commits into from Jan 29, 2019

Conversation

@eileencodes
Copy link
Member

@eileencodes eileencodes commented Jan 29, 2019

@Edouard-chin I wanted to get this in for Rails 6 (sorry for the delay before that) but there were some changes I would like to see and you seemed to be less around lately.

Hope you don't mind I took your PR and made a couple of changes:

  1. Rebased
  2. Changed s/desired_capabilities/capabilities
  3. Changed s/driver_options/capabilities
  4. Updated the docs a little

Thank you for all your work on this! I super appreciate you taking the time to improve system tests.

Update of #32442

* There is currently no way to define specific browser capabilities since our SystemTest driver override the `option` key [Ref](https://github.com/rails/rails/blob/a07d0680787ced3c04b362fa7a238c918211ac70/actionpack/lib/action_dispatch/system_testing/driver.rb#L35)
  This option key is used internally by selenium to add custom capabilities on the browser.

  Depending on the Browser, some option are allowed to be passed inside a hash, the driver takes care of setting whatever you passed on the driver option. An example [here](https://github.com/rails/rails/blob/a07d0680787ced3c04b362fa7a238c918211ac70/actionpack/lib/action_dispatch/system_testing/driver.rb#L35) where you are allowed to pass args such as `--no-sandbox` etc
  However this behavior was only meant for backward compatibility and as you can see it's deprecated.
  The non-deprecated behavior is to create a `<Driver>::Option` object containing all the capabilities we want. This is what we [currently do](https://github.com/rails/rails/blob/a07d0680787ced3c04b362fa7a238c918211ac70/actionpack/lib/action_dispatch/system_testing/browser.rb#L34-L36) when chrome or firefox are in headless mode.

  This PR allows to pass a block when calling `driven_by`, the block will be pased a `<Driver>::Option` instance. You can modify this object the way you want by adding any capabilities. The option object will be then passed to selenium.

  ```ruby
    driven_by :selenium, using: :chrome do |driver_option|
      driver_option.add_argument('--no-sandbox')
      driver_option.add_emulation(device: 'iphone 4')
    end
  ```
@eileencodes eileencodes added this to the 6.0.0 milestone Jan 29, 2019
@rails-bot rails-bot bot added the railties label Jan 29, 2019
@eileencodes eileencodes self-assigned this Jan 29, 2019
@eileencodes eileencodes force-pushed the ec-driver-option-updated branch from af264dc to 3fb4543 Jan 29, 2019
This is a minor update to the named methods for the following:

- s/desired_capabilities/capabilities
- s/driver_options/capabilities

Since they are all the same thing we should keep the name the same
throughout the feature.

Updated docs to match / be a little bit clearer

Also updated the Gemfile for selenium-webdriver.
@eileencodes eileencodes force-pushed the ec-driver-option-updated branch from 3fb4543 to 1a4f613 Jan 29, 2019
Copy link
Member

@Edouard-chin Edouard-chin left a comment

Thanks a lot Eileen for taking over and sorry for abandoning this patch 😞

@eileencodes eileencodes merged commit 94d54fa into rails:master Jan 29, 2019
2 checks passed
@eileencodes
Copy link
Member Author

@eileencodes eileencodes commented Jan 29, 2019

No worries @Edouard-chin we've all been there!

@@ -432,9 +433,9 @@ GEM
tilt (>= 1.1, < 3)
sdoc (1.0.0)
rdoc (>= 5.0)
selenium-webdriver (3.141.0)
selenium-webdriver (3.5.2)
Copy link
Member

@kamipo kamipo Jan 30, 2019

Why version locked "~> 3.5.1" (version down 3.141.0 to 3.5.2)?

Copy link
Member Author

@eileencodes eileencodes Jan 30, 2019

That was by accident. Next time you fix it in master can you leave a note here so I don't spend time starting to fix it? 😄 Thanks!

Fixed in 1cfa913

suketa added a commit to suketa/rails_sandbox that referenced this issue Aug 3, 2019
[UPDATED] Implement a way to add browser capabilities
rails/rails#35081
suketa added a commit to suketa/rails_sandbox that referenced this issue Aug 3, 2019
[UPDATED] Implement a way to add browser capabilities
rails/rails#35081
suketa added a commit to suketa/rails_sandbox that referenced this issue Aug 11, 2019
[UPDATED] Implement a way to add browser capabilities
rails/rails#35081
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants