Repository navigation
feat(driver): emulate devices from Chrome DevTools with emulate: - #338
Merged
Merged
Conversation
Add `emulate:` driver option that takes a device listed in Chrome DevTools' device toolbar, e.g. `emulate: :iphone_14`, and sets its window size, scale factor, mobile viewport with touch events and user agent. The Chrome version is filled into the device user agent as DevTools does, and it stays when other headers are set. `:mobile` and `:scale_factor` work on their own too and take precedence over the device's. They are applied in `Page#set_viewport`, so they're kept across window resizes. Closes #216, supersedes #292. Co-authored-by: Duncan Bayne <duncan@bayne.id.au>
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #292 (thanks @duncan-bayne, credited as co-author), closes #216.
emulate:takes any of the 41 devices listed in Chrome DevTools' device toolbar (Capybara::Cuprite::Devices::LIST) and sets their window size, scale factor, mobile viewport with touch events, and user agent.Chrome/%<version>sin Android/Windows user agents is filled in with the running Chrome version, as DevTools does, and the user agent stays when other headers are set.:mobileand:scale_factoralso work as standalone options and take precedence over the device's values. They're applied inPage#set_viewport, soresize_window_to,maximizeand fullscreen keep the emulation.~> 0.19.0, which enables touch emulation inPage#set_viewport(mobile: true).lib/capybara/cuprite/devices.rbfromLayout/LineLengthand stopsNaming/VariableNumberfrom checking symbols, so device names like:iphone_14pass.