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

add a device option to specify device name for convenience #129

Closed
wants to merge 4 commits into from

Conversation

nohzafk
Copy link

@nohzafk nohzafk commented Nov 7, 2023

Device name is a built-in name according to Playwright devices

For example, specify -d "iPhone 14 Prox Max" will update context_args with

{'default_browser_type': 'webkit',
 'device_scale_factor': 3,
 'has_touch': True,
 'is_mobile': True,
 'user_agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) '
               'AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4 '
               'Mobile/15E148 Safari/604.1',
 'viewport': {'height': 740, 'width': 430}}

Specifying device name will override width, height, and retina options.

Using the device name to take screenshots on Apple devices is more convenient than manually specifying the width, height, and device_scale_factor.

- Add support for specifying a device according to playwright.devices
- Update help message for `--device` option in `cli.py`
- Add `--device` option to `multi()` command in `cli.py`
@nohzafk nohzafk closed this Nov 14, 2023
@simonw
Copy link
Owner

simonw commented Nov 14, 2023

This is a neat idea for a feature.

@nohzafk nohzafk reopened this Nov 14, 2023
@nohzafk
Copy link
Author

nohzafk commented Nov 14, 2023

I closed the pull request to test the feature. Also add a device-ratio option to allow capturing only a portion of the webpage, i use it to create a screenshot of a given URL to display in my blog posts. For example, --device 'iPad Mini' --device-ratio 3:1

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.

2 participants