Below code is working fine, when I use chromedriver ver 2.28 but giving me below error 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
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);
It seems that the device was renamed to "Nexus 5".
So either create a custom device or use one from the list present in dev tools:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With