Appium XCUITest ios (React-native) app not launching

*** have completed setup of appium automation testing and it is running fine in android, but when its came to ios from command line i run “yarn testios”, test cases are started to checking but the app is not launching? why this happening and what is solution for that please guid me …**

indent preformatted text by 4 spaces
// this is "wdio.ios.config.js"  file


exports.config = {
    path: '/wd/hub/',
    port: 4729,
    services: ['appium'],
    runner: 'local',
    specs: [
        './test-ios/specs/**/*.js'
    ],
    exclude: [
    ],
    maxInstances: 1,
    capabilities: [{
        maxInstances: 1,
        browserName: '',
        appiumVersion: '1.22.0',
        platformName: 'iOS',
        platformVersion: '14.4',
        deviceName: 'iPhone 11 Pro',
        automationName: 'XCUITest',
        acceptInsecureCerts: true,
        appWaitDuration: 20000
    }],
    //app: '',
    noReset: true,
    // udid: '9084F2CE-E9B2-4632-B059-6506AA13A783',
    udid: 'FF32131D-797C-447A-B67D-D5A244AC66DF',
    autoLaunch: true,
    bundleId: 'com.callboats',
    logLevel: 'info',
    bail: 0,
    baseUrl: 'http://localhost',
    waitforTimeout: 10000,
    connectionRetryTimeout: 120000,
    connectionRetryCount: 1,
    services: ['appium'],
    framework: 'mocha',
    reporters: [['allure', {outputDir: 'allure-results'}],],
    mochaOpts: {
        ui: 'bdd',
        timeout: 60000
    },
   
    afterTest: async function(test, context, { error, result, duration, passed, retries }) {
        if (!passed) {
            await browser.takeScreenshot();
        }
    },

}




// this is package.json file
{
  "name": "testing_appium",
  "version": "1.0.0",
  "description": "automated testing with appium",
  "main": "index.js",
  "scripts": {
    "testandroid": "npx wdio ./wdio.android.conf.js",
    "testios": "npx wdio ./wdio.ios.conf.js"
  },
  "author": "TatvaSoft",
  "license": "ISC",
  "dependencies": {
    "@wdio/cli": "^7.16.10",
    "appium": "^1.22.1",
    "asyncbox": "^2.9.2",
    "chai": "^4.3.4",
    "webdriverio": "^7.16.10"
  },
  "devDependencies": {
    "@wdio/allure-reporter": "^7.16.10",
    "@wdio/appium-service": "^7.16.6",
    "@wdio/local-runner": "^7.16.10",
    "@wdio/mocha-framework": "^7.16.6",
    "wdio-mochawesome-reporter": "^4.0.0"
  }
}


// here is logs of terminal

pcq214@PCQ214 testing_appium % 
pcq214@PCQ214 testing_appium % yarn testios
yarn run v1.22.10
warning ../../../../../../package.json: No license field
$ npx wdio ./wdio.ios.conf.js
Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db

Why you should do it regularly:
https://github.com/browserslist/browserslist#browsers-data-updating

Execution of 1 workers started at 2021-12-17T09:37:28.281Z

2021-12-17T09:37:28.722Z INFO @wdio/cli:launcher: Run onPrepare hook
2021-12-17T09:37:41.615Z INFO @wdio/cli:launcher: Run onWorkerStart hook
2021-12-17T09:37:41.616Z INFO @wdio/local-runner: Start worker 0-0 with arg: ./wdio.ios.conf.js
[0-0] 2021-12-17T09:37:44.352Z INFO @wdio/local-runner: Run worker command: run
[0-0] Browserslist: caniuse-lite is outdated. Please run:
[0-0] npx browserslist@latest --update-db
[0-0] 
[0-0] Why you should do it regularly:
[0-0] https://github.com/browserslist/browserslist#browsers-data-updating
[0-0] RUNNING in iOS - /test-ios/specs/example.e2e.js
[0-0] 2021-12-17T09:37:49.187Z INFO webdriver: Initiate new session using the WebDriver protocol
[0-0] 2021-12-17T09:37:50.505Z INFO webdriver: [POST] http://localhost:4723/session
[0-0] 2021-12-17T09:37:50.505Z INFO webdriver: DATA {
[0-0]   capabilities: {
[0-0]     alwaysMatch: {
[0-0]       browserName: '',
[0-0]       appiumVersion: '1.22.0',
[0-0]       platformName: 'iOS',
[0-0]       platformVersion: '14.4',
[0-0]       deviceName: 'iPhone 11 Pro',
[0-0]       automationName: 'XCUITest',
[0-0]       acceptInsecureCerts: true,
[0-0]       appWaitDuration: 20000
[0-0]     },
[0-0]     firstMatch: [ {} ]
[0-0]   },
[0-0]   desiredCapabilities: {
[0-0]     browserName: '',
[0-0]     appiumVersion: '1.22.0',
[0-0]     platformName: 'iOS',
[0-0]     platformVersion: '14.4',
[0-0]     deviceName: 'iPhone 11 Pro',
[0-0]     automationName: 'XCUITest',
[0-0]     acceptInsecureCerts: true,
[0-0]     appWaitDuration: 20000
[0-0]   }
[0-0] }
[0-0] 2021-12-17T09:38:10.129Z INFO webdriver: COMMAND launchApp()
[0-0] 2021-12-17T09:38:10.129Z INFO webdriver: [POST] http://localhost:4723/session/5539814a-78ef-407d-935f-496b39f32403/appium/app/launch
[0-0] 2021-12-17T09:38:13.141Z INFO webdriver: COMMAND findElement("accessibility id", "settings-btn")
[0-0] 2021-12-17T09:38:13.141Z INFO webdriver: [POST] http://localhost:4723/session/5539814a-78ef-407d-935f-496b39f32403/element
[0-0] 2021-12-17T09:38:13.141Z INFO webdriver: DATA { using: 'accessibility id', value: 'settings-btn' }
[0-0] 2021-12-17T09:38:14.133Z INFO webdriver: RESULT {
[0-0]   error: 'no such element',
[0-0]   message: 'An element could not be located on the page using the given search parameters.',
[0-0]   stacktrace: 'NoSuchElementError: An element could not be located on the page using the given search parameters.\n' +
[0-0]     '    at XCUITestDriver.doNativeFind (/Users/pcq214/Desktop/react-native/testing/callboats-mobile-app/app-client-mobile/testing_appium/node_modules/appium-xcuitest-driver/lib/commands/find.js:130:11)\n' +
[0-0]     '    at processTicksAndRejections (internal/process/task_queues.js:93:5)\n' +
[0-0]     '    at XCUITestDriver.findNativeElementOrElements (/Users/pcq214/Desktop/react-native/testing/callboats-mobile-app/app-client-mobile/testing_appium/node_modules/appium-xcuitest-driver/lib/commands/find.js:90:10)\n' +
[0-0]     '    at XCUITestDriver.findElOrEls (/Users/pcq214/Desktop/react-native/testing/callboats-mobile-app/app-client-mobile/testing_appium/node_modules/appium-xcuitest-driver/lib/commands/find.js:23:12)\n' +
[0-0]     '    at XCUITestDriver.findElOrElsWithProcessing (/Users/pcq214/Desktop/react-native/testing/callboats-mobile-app/app-client-mobile/testing_appium/node_modules/appium-base-driver/lib/basedriver/commands/find.js:33:12)\n' +
[0-0]     '    at XCUITestDriver.findElement (/Users/pcq214/Desktop/react-native/testing/callboats-mobile-app/app-client-mobile/testing_appium/node_modules/appium-base-driver/lib/basedriver/commands/find.js:53:10)'
[0-0] }
[0-0] 2021-12-17T09:38:14.405Z INFO webdriver: COMMAND findElement("accessibility id", "settings-btn")
[0-0] 2021-12-17T09:38:14.405Z INFO webdriver: [POST] http://localhost:4723/session/5539814a-78ef-407d-935f-496b39f32403/element
[0-0] 2021-12-17T09:38:14.405Z INFO webdriver: DATA { using: 'accessibility id', value: 'settings-btn' }
[0-0] 2021-12-17T09:38:14.566Z INFO webdriver: RESULT {
[0-0]   error: 'no such element',
[0-0]   message: 'An element could not be located on the page using the given search parameters.',
[0-0]   stacktrace: 'NoSuchElementError: An element could not be located on the page using the given search parameters.\n' +
[0-0]     '    at XCUITestDriver.doNativeFind (/Users/pcq214/Desktop/react-native/testing/callboats-mobile-app/app-client-mobile/testing_appium/node_modules/appium-xcuitest-driver/lib/commands/find.js:130:11)\n' +
[0-0]     '    at processTicksAndRejections (internal/process/task_queues.js:93:5)\n' +
[0-0]     '    at XCUITestDriver.findNativeElementOrElements (/Users/pcq214/Desktop/react-native/testing/callboats-mobile-app/app-client-mobile/testing_appium/node_modules/appium-xcuitest-driver/lib/commands/find.js:90:10)\n' +
[0-0]     '    at XCUITestDriver.findElOrEls (/Users/pcq214/Desktop/react-native/testing/callboats-mobile-app/app-client-mobile/testing_appium/node_modules/appium-xcuitest-driver/lib/commands/find.js:23:12)\n' +
[0-0]     '    at XCUITestDriver.findElOrElsWithProcessing (/Users/pcq214/Desktop/react-native/testing/callboats-mobile-app/app-client-mobile/testing_appium/node_modules/appium-base-driver/lib/basedriver/commands/find.js:33:12)\n' +
[0-0]     '    at XCUITestDriver.findElement (/Users/pcq214/Desktop/react-native/testing/callboats-mobile-app/app-client-mobile/testing_appium/node_modules/appium-base-driver/lib/basedriver/commands/find.js:53:10)'
[0-0] }
[0-0] 2021-12-17T09:38:14.889Z INFO webdriver: COMMAND findElement("accessibility id", "settings-btn")
[0-0] 2021-12-17T09:38:14.890Z INFO webdriver: [POST] http://localhost:4723/session/5539814a-78ef-407d-935f-496b39f32403/element
[0-0] 2021-12-17T09:38:14.890Z INFO webdriver: DATA { using: 'accessibility id', value: 'settings-btn' }
[0-0] 2021-12-17T09:38:15.019Z INFO webdriver: RESULT {
[0-0]   error: 'no such element',
[0-0]   message: 'An element could not be located on the page using the given search parameters.',
[0-0]   stacktrace: 'NoSuchElementError: An element could not be located on the page using the given search parameters.\n' +
[0-0]     '    at XCUITestDriver.doNativeFind (/Users/pcq214/Desktop/react-native/testing/callboats-mobile-app/app-client-mobile/testing_appium/node_modules/appium-xcuitest-driver/lib/commands/find.js:130:11)\n' +
[0-0]     '    at processTicksAndRejections (internal/process/task_queues.js:93:5)\n' +
[0-0]     '    at XCUITestDriver.findNativeElementOrElements (/Users/pcq214/Desktop/react-native/testing/callboats-mobile-app/app-client-mobile/testing_appium/node_modules/appium-xcuitest-driver/lib/commands/find.js:90:10)\n' +
[0-0]     '    at XCUITestDriver.findElOrEls (/Users/pcq214/Desktop/react-native/testing/callboats-mobile-app/app-client-mobile/testing_appium/node_modules/appium-xcuitest-driver/lib/commands/find.js:23:12)\n' +
[0-0]     '    at XCUITestDriver.findElOrElsWithProcessing (/Users/pcq214/Desktop/react-native/testing/callboats-mobile-app/app-client-mobile/testing_appium/node_modules/appium-base-driver/lib/basedriver/commands/find.js:33:12)\n' +
[0-0]     '    at XCUITestDriver.findElement (/Users/pcq214/Desktop/react-native/testing/callboats-mobile-app/app-client-mobile/testing_appium/node_modules/appium-base-driver/lib/basedriver/commands/find.js:53:10)'
[0-0] }
[0-0] 2021-12-17T09:38:15.172Z INFO webdriver: COMMAND findElement("accessibility id", "settings-btn")
[0-0] 2021-12-17T09:38:15.173Z INFO webdriver: [POST] http://localhost:4723/session/5539814a-78ef-407d-935f-496b39f32403/element
[0-0] 2021-12-17T09:38:15.173Z INFO webdriver: DATA { using: 'accessibility id', value: 'settings-btn' }
^C

Ending WebDriver sessions gracefully ...
(press ctrl+c again to hard kill the runner)
2021-12-17T09:38:15.204Z INFO @wdio/local-runner: Shutting down spawned worker
[0-0] 2021-12-17T09:38:15.204Z INFO @wdio/local-runner: Received SIGINT, giving process 5000ms to shutdown gracefully
[0-0] 2021-12-17T09:38:15.206Z INFO @wdio/local-runner: Run worker command: endSession
[0-0] 2021-12-17T09:38:15.206Z INFO webdriver: COMMAND deleteSession()
[0-0] 2021-12-17T09:38:15.206Z INFO webdriver: [DELETE] http://localhost:4723/session/5539814a-78ef-407d-935f-496b39f32403
//continue...........................................and fail cases because app is not launching




//here is starting of my test cases.....in "example.e2e.js"


// it will launch the application
describe('launch the app', ()=>{
    before(()=>{
        it("should launch the app", async ()=>{
            let driver = await initSession();
            //let driver = new AndroidDriver();
            //await driver.launchApp('com.callboats');
            //await driver.activateApp('com.callboats');
            await driver.execute('mobile: launchApp');
            await $("~map-view").waitForDisplayed(20000, false)
        })
    })
});

//it will check the flow of trip as anonymous user
describe('testing enjoy trip as anonymous user', ()=> {

    it('should render mapView', async ()=>{
        await driver.launchApp();

        await browser.waitUntil(
            async () => (await  $("~settings-btn").isDisplayed()) == true,
            {
                timeout: 50000,
                timeoutMsg: 'id(settings-btn) is not displayed'
            }
        );
        await browser.waitUntil(
            async () => (await  $("~map-view").isDisplayed()) == true,
            {
                timeout: 50000,
                timeoutMsg: 'id(map-view) is not displayed'
            }
        );
        await browser.waitUntil(
            async () => (await  $("~main-mapview").isDisplayed()) == true,
            {
                timeout: 50000,
                timeoutMsg: 'id(main-mapview) is not displayed'
            }
        );
    }).....................continue

For iOS, add app: capability with value as path to app you want to test.

1 Like

thanks for replying @wreed , the problem was, i passed bundleId in wrong object(direct into global config as you can see in above mentioned code.), it should be in capabalities:{…},