Mobile Testing

SeleniumBase

Mobile Testing

Use --mobile to run your SeleniumBase tests using Chromium's mobile device emulator with default values for device metrics (CSS Width, CSS Height, Pixel-Ratio) and user agent.

To configure the mobile device metrics, use:

--metrics="CSS_Width,CSS_Height,Pixel_Ratio"

To configure the user agent, use:

--agent="USER-AGENT-STRING"

To find real values for device metrics, see: * Device Metrics List

For a list of available user agent strings, see: * User Agent Strings List


Here's an example of running a mobile test:

pytest test_skype_site.py --mobile


Here's another example of running a mobile test (SeleniumBase/examples/test_swag_labs.py), which demonstrates using --metrics and --agent with --mobile:

# Run tests using Chrome's mobile device emulator (default settings)
pytest test_swag_labs.py --mobile

# Run mobile tests specifying CSS Width, CSS Height, and Pixel-Ratio
pytest test_swag_labs.py --mobile --metrics="411,731,3"

# Run mobile tests specifying the user agent
pytest test_swag_labs.py --mobile --agent="Mozilla/5.0 (Linux; Android 9; Pixel 3 XL)"