单击方法不适用于 chrome 模拟器
Click method is not working with chrome emulator
以下是我的设置的详细信息:
chrome=67.0.3396.87,
chromedriver=2.40.565498,
selenium version-2.53.0
下面是模拟器代码-
public ChromeOptions getChromeEmulators(int width, int height) {
Map<String, Object> deviceMetrics = new HashMap<String, Object>();
Map<String, Object> mobileEmulation = new HashMap<String, Object>();
ChromeOptions chromeOptions = new ChromeOptions();
try {
deviceMetrics.put("width", width);
deviceMetrics.put("height", height);
deviceMetrics.put("pixelRatio", 3.0);
mobileEmulation.put("deviceMetrics", deviceMetrics);
mobileEmulation.put("userAgent",
"Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D)
AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile
Safari/535.19");
chromeOptions.setExperimentalOption("mobileEmulation", mobileEmulation);
}catch (Exception e) {
e.printStackStarce();
}
return chromeOptions;
}
点击选项不适用于 chrome 模拟器,但它适用于具有以上版本的 chrome 浏览器。有人可以帮忙吗?
这是 chrome驱动程序自过去几个版本以来就存在的已知问题。还没有修复。此时,唯一的解决方法是使用 chromerdriver : 2.33.506120 + chrome : 61.0.3163.79
参考以下错误:
https://bugs.chromium.org/p/chromedriver/issues/detail?id=2144&desc=2
https://bugs.chromium.org/p/chromedriver/issues/detail?id=2172
或者,您可以尝试 JavascriptExecutor(尽管这不是首选)
JavascriptExecutor script click. JavascriptExecutor js = (JavascriptExecutor)
driver; js.executeScript("arguments[0].click();",element);
以下是我的设置的详细信息:
chrome=67.0.3396.87, chromedriver=2.40.565498, selenium version-2.53.0
下面是模拟器代码-
public ChromeOptions getChromeEmulators(int width, int height) {
Map<String, Object> deviceMetrics = new HashMap<String, Object>();
Map<String, Object> mobileEmulation = new HashMap<String, Object>();
ChromeOptions chromeOptions = new ChromeOptions();
try {
deviceMetrics.put("width", width);
deviceMetrics.put("height", height);
deviceMetrics.put("pixelRatio", 3.0);
mobileEmulation.put("deviceMetrics", deviceMetrics);
mobileEmulation.put("userAgent",
"Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D)
AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile
Safari/535.19");
chromeOptions.setExperimentalOption("mobileEmulation", mobileEmulation);
}catch (Exception e) {
e.printStackStarce();
}
return chromeOptions;
}
点击选项不适用于 chrome 模拟器,但它适用于具有以上版本的 chrome 浏览器。有人可以帮忙吗?
这是 chrome驱动程序自过去几个版本以来就存在的已知问题。还没有修复。此时,唯一的解决方法是使用 chromerdriver : 2.33.506120 + chrome : 61.0.3163.79
参考以下错误:
https://bugs.chromium.org/p/chromedriver/issues/detail?id=2144&desc=2
https://bugs.chromium.org/p/chromedriver/issues/detail?id=2172
或者,您可以尝试 JavascriptExecutor(尽管这不是首选)
JavascriptExecutor script click. JavascriptExecutor js = (JavascriptExecutor)
driver; js.executeScript("arguments[0].click();",element);