Skip to content

Commit

Permalink
add google chrome device emulation recipe to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
konstunn authored and dimaqq committed Jan 12, 2021
1 parent 912c64c commit 942d0a0
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions docs/reference/supported-browsers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,50 @@ To use Google Chrome headless, use::
...


Google Chrome Device Emulation
******************************

To enable device emulation mode with Google Chrome, you can use::

from arsenic import services, browsers, get_session

service = services.Chromedriver()

device_metrics = dict(width=640, height=480, pixelRatio=1.0)

mobile_emulation = dict(deviceMetrics=device_metrics)

kwargs = {'goog:chromeOptions': dict(mobileEmulation=mobile_emulation)}

browser = browsers.Chrome(**kwargs)

async with get_session(service, browser) as session:
...


Google Chrome Device Emulation And Headless
*******************************************

To enable device emulation mode and headless mode at the same time with Google Chrome, you can use::


from arsenic import services, browsers

service = services.Chromedriver(binary='chromedriver')

device_metrics = dict(width=640, height=480, pixelRatio=1.0)

mobile_emulation = dict(deviceMetrics=device_metrics)

args=['--headless', '--disable-gpu']
kwargs = {'goog:chromeOptions': dict(mobileEmulation=mobile_emulation, args=args)}

browser = browsers.Chrome(**kwargs)

async with get_session(service, browser) as session:
...


Headless Firefox
****************

Expand Down

0 comments on commit 942d0a0

Please sign in to comment.