【问题标题】:Selenium - mobileEmulation not working after chromedriver version updation to 2.30Selenium - chromedriver 版本更新到 2.30 后,移动仿真无法正常工作
【发布时间】: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


    【解决方案1】:

    该设备似乎已重命名为“Nexus 5”。

    因此,要么创建一个自定义设备,要么使用开发工具列表中的一个:

    • 黑莓 Z30
    • 黑莓手册
    • 银河注 3
    • 银河注 II
    • 银河 S III
    • Kindle Fire HDX
    • LG 擎天柱 L70
    • 带 HiDPI 屏幕的笔记本电脑
    • 带 MDPI 屏幕的笔记本电脑
    • 带触控功能的笔记本电脑
    • 微软 Lumia 550
    • 微软 Lumia 950
    • Nexus 10
    • Nexus 4
    • Nexus 5
    • Nexus 6
    • Nexus 7
    • 诺基亚 Lumia 520
    • 诺基亚 N9
    • iPad 迷你
    • iPhone 4
    • 银河 S5
    • Nexus 5X
    • Nexus 6P
    • iPhone 5
    • iPhone 6
    • iPhone 6 Plus
    • iPad

    【讨论】:

    • 移动仿真仅适用于您答案中的开箱即用设备列表,为什么我的自定义设备不起作用?
    猜你喜欢
    • 2019-07-04
    • 2022-08-02
    • 1970-01-01
    • 2023-01-13
    • 1970-01-01
    • 1970-01-01
    • 2017-02-01
    • 2019-12-26
    • 1970-01-01
    相关资源
    最近更新 更多