Selenium - mobileEmulation does not work after upgrading chrome rib version to 2.30

The code below works fine when I use chromedriver ver 2.28, but the error below when I use Chromedriver ver 2.30

Stack trace:

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

The code:

    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);
+4
source share
1 answer

It seems that the device has been renamed to "Nexus 5".

So, create your own device or use it in the list provided in dev tools:

  • Blackberry z30
  • Blackberry playbook
  • Galaxy Note 3
  • Galaxy Note II
  • Galaxy S III
  • Kindle Fire HDX
  • LG Optimus L70
  • Laptop with HiDPI Screen
  • Laptop with MDPI screen
  • Touchscreen laptop
  • Microsoft Lumia 550
  • Microsoft Lumia 950
  • Nexus 10
  • Nexus 4
  • Nexus 5
  • Nexus 6
  • Nexus 7
  • Nokia Lumia 520
  • Nokia N9
  • iPad Mini
  • iPhone 4
  • Galaxy S5
  • Nexus 5X
  • Nexus 6P
  • iPhone 5
  • iPhone 6
  • iPhone 6 Plus
  • IPad
+4

Source: https://habr.com/ru/post/1679331/


All Articles