如何配置 Chimp 以打开具有给定宽度和高度的浏览器?

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

最近我开始使用 Chimp 并且我的测试套件在不断增长。我想在移动视口上实现一个我需要 运行 的功能(例如测试汉堡菜单)。我用@mobile 标签标记了这样的场景。

Chimp 默认 运行 在 Chrome webdriver 中以我桌面屏幕一半的分辨率(在我的例子中是 931x1013px)但我希望它 运行 例如640x960 phone 分辨率)。

我知道我可以使用配置文件配置我的 Chimp 会话,但我找不到控制 Chrome 实例的浏览器分辨率的设置。我找到了 phantom_w / phantom_h 设置,但似乎与 Chrome 网络驱动程序无关。

如何在特定分辨率下强制我的 Chrome 网络驱动程序 运行?我可以配置 Chimp 这样做吗,也许是通过 desiredCapabilities - 但是如何?

注意:我使用的是 Node 6.4、NPM 3.10.5 和 Chimp 0.34,到目前为止所有功能都可以正常工作。

有两种方法。

  1. 使用 @grasshopper 提到的 setViewPortSize
  2. 使用 chrome 的移动仿真。

对于2,您需要设置desiredCapabilities 你可以在黑猩猩配置中这样做: https://github.com/xolvio/chimp/blob/master/src/bin/default.js#L48

然后您需要以与他们在此处执行的方式类似的方式设置移动仿真: https://sites.google.com/a/chromium.org/chromedriver/mobile-emulation