I'm currently trying to add mobileEmulation capabilities into ms:edgeOptions through my beforeSession hook when specific spec is being run. Framework is using wdio v7.9.
When adding mobileEmulation:{'deviceName': 'iPhone X'} into the capabilities at the top of wdio.conf this works without issue.
The issue occurs during the hook, which is where I need this as I only need it to run for this specific spec and not the rest of the suite.
beforeSession Hook:
if(capabilities.browserName === 'MicrosoftEdge' && specs.toString() === '[PathToSpecFile]'){
capabilities['ms:edgeOptions'].mobileEmulation = 'iPhone X';
console.log('##########', capabilities);
}
The console output shows the capabilities have been set as expected:
########## {
[0-0] maxInstances: 1,
[0-0] browserName: 'MicrosoftEdge',
[0-0] 'ms:edgeOptions': {
[0-0] args: [],
[0-0] prefs: {
[0-0] 'download.default_directory': '[PATH]'
[0-0] },
[0-0] mobileEmulation: 'iPhone X'
[0-0] },
[0-0] protocol: 'http',
[0-0] hostname: 'localhost',
[0-0] port: 4444,
[0-0] path: '/wd/hub'
[0-0] }
However when attempting to create the session I'm getting the following error output:
ERROR webdriver: Request failed with status 500 due to session not created: Unable to create session from {
[0-0] "desiredCapabilities": {
[0-0] "browserName": "MicrosoftEdge",
[0-0] "ms:edgeOptions": {
[0-0] "args": [
[0-0] ],
[0-0] "prefs": {
[0-0] "download.default_directory": "[PATH]"
[0-0] },
[0-0] "mobileEmulation": "iPhone X"
[0-0] }
[0-0] },
[0-0] "capabilities": {
[0-0] "firstMatch": [
[0-0] {
[0-0] "browserName": "MicrosoftEdge",
[0-0] "ms:edgeOptions": {
[0-0] "args": [
[0-0] ],
[0-0] "prefs": {
[0-0] "download.default_directory": "[PATH]"
[0-0] },
[0-0] "mobileEmulation": "iPhone X"
[0-0] }
[0-0] }
[0-0] ]
[0-0] }
[0-0] }
[0-0] Driver info: driver.version: unknown