How to execute test on Browsersatck on iPhone safari?

Hi,
I am trying to run tests on BrowserStack using Codecept on iPhone -safari combination. However I am unable to do so.

Following are some issues I am encountering:

  1. Tests By default run on Chrome, if I put browser name as Chrome. Desired capabilities are getting ignored
  2. Test fail error “Parameters were incorrect. We wanted {“required”:[“type”,“ms”]} and you sent [“script”]” if i put browser as “iPhone”
  3. Test fail error “Unknown command: setTimeout (WARNING: The server did not provide any stacktrace information)” and OS shown in capabilities on Dashboard is MAC if I run tests using Browser as safari
  4. Test fails with error " WebDriver requires at url and browser to be set." if I dont set browser.

Please let me know if it is practically possible to run test on Android/ iOs devoices using browserstack with Codecept ?

@sgurm This is my iOS config for running on cloud
WebDriver: {
url: ‘http://hub.lambdatest.com/wd/hub’,
browser: ‘safari’,
smartWait: 5000,
host: ‘hub.lambdatest.com’,
port: 80,
user: ‘’,
key: ‘’,
desiredCapabilities: {
name: “Codeceptio Sample Test”,
platformName: “iOS”,
browserName: ‘safari’,
deviceName: ‘iPhone XS’,
platformVersion: ‘12.1’,
video: ‘true’,
w3c: ‘true’,
tunnel: ‘true’
},
}Preformatted text

Yes it is possible, but we had the same issue with the error: We wanted {“required”:[“type”,“ms”]} and you sent [“script”]”

This error occurs because the smartWait parameter is somehow sent in a wrong format.
To workaround this issue, you must delete the smartWait parameter in the WebDriver config.
We do it in the codeceptjs.conf.js via:
delete config.helpers.WebDriver.smartWait (the default config is for chrome that’s why we delete it afterwards only when we run the tests on iphone)
We also have to do this for iphone:
// windowSize is not supported for mobile device
delete config.helpers.WebDriver.windowSize;

How do you set your desired capabilities for the WebDriver?
For us it works when we set them like this:
config.helpers.WebDriver.desiredCapabilities = {
device: “iPhone 8”,
browser: “safari”,
realMobile: “true”,
os_version: “11”,
“browserstack.appium_version”: “1.14.0”
};

Hi @christian_wolf,
Thanks for writing back.
I am still not able to get the desired output. Getting same error.

Following is my helper config

helpers: {

WebDriver:{

user: "ncxc,",

key: "xncjxc,z",

url:urlReact,

browser:'chrome',

desiredCapabilities :{

  device: 'iPhone 8',

  browser: 'safari',

  realMobile: 'true',

  os_version: '11',

  'browserstack.appium_version': '1.14.0'

  }

   

}

@sgurm

You must set host to use browserstack:

Webdriver: {

host: “hub-cloud.browserstack.com”,
user: …

}

When you run this you should at least see that something was invoked on BS, when you login to Browserstack (https://automate.browserstack.com/ is the page to open)

I havetried that too but the error remains same. Can you share your sample config file, where u got success in launching test on iPhone @BS?

Here is a sample config that works for us.

const config = {
tests: “…/scenarios/*_test.js”,
output: “…/output”,

helpers: {
WebDriver: {
url: “http://www.google.de”,
host: “hub-cloud.browserstack.com”,
browser: “safari”,
// unit: ms
smartWait: 10000,
// unit: ms
waitForTimeout: 20000,

  windowSize: "1920x1080",
  desiredCapabilities: {
    project: "test",
    resolution: "1920x1080",
    "browserstack.selenium_version": "3.14.0",
    device: "iPhone 8",
    realMobile: "true",
    os_version: "11",
    "browserstack.appium_version": "1.14.0"
  },
  // If present in ENV vars, CodeceptJS will use BrowserStack,
  // otherwise it falls back to local browser defined above
  user: process.env.BROWSERSTACK_USER,
  key: process.env.BROWSERSTACK_KEY
}

},
bootstrap: null,
mocha: {},
name: “test”
};

// windowSize is not supported by appium so we delete it.
delete config.helpers.WebDriver.windowSize;

// smartWait parameter format is sent incorrect to appium and that’s why we must delete it.
delete config.helpers.WebDriver.smartWait;

exports.config = config;

You just have to set the BS user/key as environment variables before:
export BROWSERSTACK_USER=username
export BROWSERSTACK_KEY=keyvalue

Thanks, but it isnt working again. Following is my config file:

const config = {

tests: ‘./Tests/reactAppTest.js’,

output: ‘./output’,

timeout: 30000,

include: {

homePage: "./pages/angular1/homePage.js",

TutorialPage: "./pages/angular1/TutorialPage.js",

profilePage: "./pages/angular2/profilePage.js",

interestsPage: "./pages/angular2/interestsPage.js",

commonPage: "./pages/angular2/commonPage.js",

completedPage: "./pages/angular2/completedPage.js",

mainPage: "./pages/react/mainPage.js"

},

helpers: {

WebDriver: {

  url: 'http://www.google.de',

  host: 'hub-cloud.browserstack.com',

  browser: 'safari',

  // unit: ms

  smartWait: 10000,

  // unit: ms

  waitForTimeout: 20000,

  

    windowSize: "1920x1080",

    desiredCapabilities: {

      project: "test",

      resolution: "1920x1080",

      "browserstack.selenium_version": "3.14.0",

      device: "iPhone 8",

      realMobile: "true",

      os_version: "11",

      "browserstack.appium_version": "1.14.0"

    },

    

    user: ',mcvmc,', 

    key: 'ccdcmd'

  }

},

bootstrap: null,

mocha: {},

name: ‘Codecept-example’,

plugins: {

retryFailedStep: {

  enabled: true

},

screenshotOnFail: {

  enabled: true,

  outputDir: "./output/allure-results"

},

allure: {

  enabled: true,

  outputDir: "./output/allure-results"

},

autoDelay: {

  enabled: true

},

"stepByStepReport": {

  "enabled": true

},

wdio: { // required for Protractor and selenium

  enabled: true,

  services: ['browserstack'],

  user: 'm m,cxz', // credentials

  key: 'mc ,'

}

}

};

delete config.helpers.WebDriver.windowSize;

delete config.helpers.WebDriver.smartWait;

exports.config = config;

What error(s) do you get?

× “before each” hook: codeceptjs.before for “Register to react app” in 58937ms
Error: Parameters were incorrect. We wanted “MJSONWP protocol requires type and ms” and you sent {“script”:1000}

– FAILURES:

  1. Login/Register to React Application
    “before each” hook: codeceptjs.before for “Register to react app”:
    Parameters were incorrect. We wanted “MJSONWP protocol requires type and ms” and you sent {“script”:1000}

Run with --verbose flag to see NodeJS stacktrace

hm, that’s weird. Can you try with
"browserstack.appium_version": "1.16.0"
"browserstack.selenium_version": "3.141.59",

which codeceptjs version are you running?

Latest: 2.4.3.

Also no luck with the latest configs you sent . Following are the dependencies in my package.json

“dependencies”: {

"codeceptjs": "2.4.3",

"puppeteer": "^1.6.0",

"del-cli": "^3.0.0",

"protractor": "5.4.3",

"nightmare": "3.0.2",

"testcafe": "1.8.1",

"@wdio/selenium-standalone-service": "5.16.10",

"browserstack": "1.5.3",

"appium": "1.16.0",

"@wdio/browserstack-service": "5.18.1",

"webdriverio": "5.18.6"

},

@sgurm google search for the error brought me to this discussion:

I think the last comments might be useful for you.
I hope you get it running soon!

Hi Christian,

That was helpful with some little changes required.

Thanks my problem is resolved now.

Regards,

Sheena

Is this issue resolved for you or working at your end?? please help if it works.

Can you post your fix? I am also facing this issue.