Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
`Ferrum::JavaScriptError: node.getRootNode(...).elementFromPoint is not a function` [#359]
- `Driver#reset!` and `Driver#quit` don't launch Chrome when no browser has started, so a failed launch doesn't
launch again during teardown
- The `:emulate` device user agent is set with Ferrum's `network.emulate`, so clearing its other overrides keeps the
device user agent instead of falling back to Chrome's

### Removed
- Methods deprecated in 0.20, see its Deprecated section for replacements
Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/cuprite/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def prepare_page

width, height = @options.window_size
width && height ? resize(width: width, height: height) : set_viewport
command("Network.setUserAgentOverride", userAgent: default_user_agent) if @options.device_user_agent
network.emulate(user_agent: default_user_agent) if @options.device_user_agent

if @options.url_blacklist.any?
network.blacklist = @options.url_blacklist
Expand Down
9 changes: 9 additions & 0 deletions spec/driver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ def session_url(path)
expect(@driver.html).to include("DV: hello")
expect(@session.evaluate_script("navigator.userAgent")).to start_with("Mozilla/5.0 (iPhone;")
end

it "keeps the device user agent when Ferrum's emulate overrides are cleared" do
@driver.browser.network.emulate(accept_language: "de-DE")
@driver.browser.network.emulate(accept_language: nil)
@session.visit("/cuprite/headers")

expect(@driver.html).to include("USER_AGENT: Mozilla/5.0 (iPhone; CPU iPhone OS")
expect(@session.evaluate_script("navigator.userAgent")).to start_with("Mozilla/5.0 (iPhone;")
end
end

context "with emulate: and explicit options" do
Expand Down
Loading