Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

97
Views
WebdriverIO error when adding capabilities to edgeOptions in beforeSession hook

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
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!