小编Abh*_*yal的帖子

Selenium - 在chromedriver版本更新到2.30后,mobileEmulation无法正常工作

下面的代码工作正常,当我使用chromedriver ver 2.28但是当我使用Chromedriver ver 2.30时给出以下错误

堆栈跟踪:

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
Run Code Online (Sandbox Code Playgroud)

码:

    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 = …
Run Code Online (Sandbox Code Playgroud)

selenium selenium-chromedriver

4
推荐指数
1
解决办法
2783
查看次数

标签 统计

selenium ×1

selenium-chromedriver ×1