简体   繁体   中英

How can I configure Chimp to open a browser with given width and height?

Recently I started with Chimp and my test suite is growing. I want to implement a feature that I need to run on a mobile viewport specifically (eg to test Hamburger menu). I tag such a scenario with the @mobile tag.

Chimp is by default running in the Chrome webdriver at a resolution of half my desktop screen (931x1013px in my case) but I want it to run in eg 640x960 phone resolution).

I know I can configure my Chimp session using a configuration file, but I cannot find the setting that controls the browser resolution for my Chrome instance. I found a phantom_w / phantom_h setting but appears to be unrelated to the Chrome webdriver.

How can I force my Chrome webdriver to run at a specific resolution? Can I configure Chimp to do so, perhaps via the desiredCapabilities - but how?

Note: I'm using Node 6.4, NPM 3.10.5 and Chimp 0.34 and this works fine for all features so far.

There are two ways.

  1. Using setViewPortSize as @grasshopper has mentioned
  2. Using chrome's mobile emulation.

For 2, you need to set the desiredCapabilities You can do that in the chimp config like this: https://github.com/xolvio/chimp/blob/master/src/bin/default.js#L48

Then you need to set the mobile emulation in a similar fashion to how they do it here: https://sites.google.com/a/chromium.org/chromedriver/mobile-emulation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM