【发布时间】:2017-06-15 10:07:10
【问题描述】:
当我使用 chromedriver 2.28 版时,下面的代码工作正常,但当我使用 2.30 版 Chromedriver 时出现以下错误
堆栈跟踪:
org.openqa.selenium.WebDriverException: unknown error: cannot parse
capability: chromeOptions
from unknown error: cannot parse mobileEmulation
from unknown error: 'Google Nexus 5' must be a valid device
from unknown error: must be a valid device
代码:
String chromedriver = CONFIG.getProperty("chromedriverpath");
System.setProperty("webdriver.chrome.driver", chromedriver);
Map<String, String> mobileEmulation = new HashMap<String, String>();
mobileEmulation.put("deviceName", "Google Nexus 5");
Map<String, Object> chromeOptions = new HashMap<String, Object>();
chromeOptions.put("mobileEmulation", mobileEmulation);
chromeOptions.put("args", Arrays.asList("--disable-extensions",
"no-sandbox", "--allow-running-insecure-content", "ignore-
certificate-errors","disable-infobars"));
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
WebDriver driver = new ChromeDriver(capabilities);
【问题讨论】:
标签: selenium selenium-chromedriver