需要在桌面浏览器上使用移动设备仿真来自动化测试。
如果通过ChromeOptions()启用仿真,则触摸屏的仿真不起作用(按钮响应光标等)。这就是为什么我使用java.awt.Robot(F12> Ctrl + Shift + M> iPad)打开设备仿真的原因。但是触摸不起作用。
struct packet_time_entry {
linkaddr_t *source;
uint32_t time;
};
MEMB(packet_time_mem, struct packet_time_entry, 16);
LIST(packet_time);
没有按下该按钮,也没有错误-“退出代码为0的过程完成”
也许还有另一种启用移动设备仿真或使用TouchAction的方法?
答案 0 :(得分:0)
根据官方网站http://chromedriver.chromium.org/mobile-emulation上的规范,要在ChromeDriver中正确使用移动设备仿真,应使用:
Map<String, String> mobileEmulation = new HashMap<>();
mobileEmulation.put("deviceName", "Nexus 5");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setExperimentalOption("mobileEmulation", mobileEmulation);
WebDriver driver = new ChromeDriver(chromeOptions)
*也可以将仿真设备设为自定义,为此,您需要使用存储的自定义设备属性声明自定义会话存储。之所以需要这样做,是因为如果您没有特别声明chrome会话存储,则每次启动新的测试会话时,都会创建一个具有默认设置的临时会话。
在这里,您会发现有用的命令行来启动chromedriver: https://peter.sh/experiments/chromium-command-line-switches/#user-data-dir