Reputation: 72
Trying to setup e2e tests using emulation of mobile devices with chromedriver. We are using chromedriver 2.3 on Mac OS and it appears that the supplied chromeOptions are not valid:
var webdriver = require('selenium-webdriver');
var capabilities = {
browserName: 'chrome',
chromeOptions: {
mobileEmulation: {
deviceName: 'Apple iPhone 5'
}
}
};
var driver = new webdriver
.Builder()
.withCapabilities(capabilities)
.build();
driver.get('http://google.com');
var bool = false;
setTimeout(function () {
bool = true;
}, 9000);
driver.wait(function() {
return bool;
}, 10000);
driver.quit();
What am I doing wrong? Here is the stack trace of the error:
UnknownError: unknown error: cannot parse capability: chromeOptions
from unknown error: unrecognized chrome option: mobileEmulation
(Driver info: chromedriver=2.3,platform=Mac OS X 10.10.1 x86_64)
at new bot.Error (/Users/michael/cdTest/node_modules/selenium-webdriver/lib/atoms/error.js:113:18)
at Object.bot.response.checkResponse (/Users/michael/cdTest/node_modules/selenium-webdriver/lib/atoms/response.js:106:9)
at /Users/michael/cdTest/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:152:24
at /Users/michael/cdTest/node_modules/selenium-webdriver/lib/goog/base.js:1582:15
at webdriver.promise.ControlFlow.runInNewFrame_ (/Users/michael/cdTest/node_modules/selenium-webdriver/lib/webdriver/promise.js:1654:20)
at notify (/Users/michael/cdTest/node_modules/selenium-webdriver/lib/webdriver/promise.js:465:12)
at notifyAll (/Users/michael/cdTest/node_modules/selenium-webdriver/lib/webdriver/promise.js:442:7)
at resolve (/Users/michael/cdTest/node_modules/selenium-webdriver/lib/webdriver/promise.js:420:7)
at fulfill (/Users/michael/cdTest/node_modules/selenium-webdriver/lib/webdriver/promise.js:535:5)
at /Users/michael/cdTest/node_modules/selenium-webdriver/lib/goog/base.js:1582:15
Upvotes: 2
Views: 3222
Reputation: 168
this code definitely works in nodeJS and selenium-webdriver: ^4.0.0-alpha.1 and chrome 71; just mind that from time to time, the list
deviceName: 'Apple iPhone 5'
will change with new devices and older ones removed.
Upvotes: 0
Reputation: 21
I had the same issue with Chrome Driver 2.9 and it works fine now since I replaced it with the newest Chrome Driver 2.15.
Upvotes: 2