I read the link and tried the below code:
My code:
const wdio = require('webdriverio');
const assert = require('assert');
const find = require('appium-flutter-finder');
const osSpecificOps = process.env.APPIUM_OS === 'android' ? {
platformName: 'Android',
deviceName: 'Pixel 5 API 30',
// @todo support non-unix style path
app:'../build/app/outputs/flutter-apk/app-stage-debug.apk',
}: process.env.APPIUM_OS === 'ios' ? {
platformName: 'iOS',
platformVersion: '15.4',
deviceName: 'iPhone 13',
noReset: true,
app: '/Users/builder/Library/Developer/Xcode/DerivedData/Runner-edaimyiflreloheqntgnhkmwcclv/Build/Products/Debug-iphonesimulator/Runner.app',
} : {};
const opts = {
port: 4723,
capabilities: {
...osSpecificOps,
automationName: 'Flutter',
retryBackoffTime: 500,
}
};
(async () => {
console.log('Initial app testing');
const driver = await wdio.remote(opts);
// // Enter login page
await driver.execute('flutter:waitFor', find.byValueKey('button_sign_in_google'));
driver.deleteSession();
})();
Error while testing the code
~/Dev/work/repos/gelato-api-mobile/integration-tests # APPIUM_OS=ios npm start
> [email protected] start /Users/harsha.sharmagelato.com/Dev/work/repos/gelato-api-mobile/integration-tests
> node ./src/stepDefinitions/test.js
Initial app testing
2022-06-30T15:20:23.144Z INFO webdriver: Initiate new session using the WebDriver protocol
2022-06-30T15:20:23.178Z INFO webdriver: [POST] http://127.0.0.1:4723/session
2022-06-30T15:20:23.178Z INFO webdriver: DATA {
capabilities: {
alwaysMatch: {
platformName: 'iOS',
platformVersion: '15.4',
deviceName: 'iPhone 13',
noReset: true,
app: '/Users/builder/Library/Developer/Xcode/DerivedData/Runner-edaimyiflreloheqntgnhkmwcclv/Build/Products/Debug-iphonesimulator/Runner.app',
automationName: 'Flutter',
retryBackoffTime: 500
},
firstMatch: [ {} ]
},
desiredCapabilities: {
platformName: 'iOS',
platformVersion: '15.4',
deviceName: 'iPhone 13',
noReset: true,
app: '/Users/builder/Library/Developer/Xcode/DerivedData/Runner-edaimyiflreloheqntgnhkmwcclv/Build/Products/Debug-iphonesimulator/Runner.app',
automationName: 'Flutter',
retryBackoffTime: 500
}
}
2022-06-30T15:20:23.186Z ERROR webdriver: RequestError: connect ECONNREFUSED 127.0.0.1:4723
at ClientRequest.<anonymous> (/Users/harsha.sharmagelato.com/Dev/work/repos/gelato-api-mobile/integration-tests/node_modules/got/dist/source/core/index.js:962:111)
at Object.onceWrapper (events.js:520:26)
at ClientRequest.emit (events.js:412:35)
at ClientRequest.emit (domain.js:475:12)
at ClientRequest.origin.emit (/Users/harsha.sharmagelato.com/Dev/work/repos/gelato-api-mobile/integration-tests/node_modules/@szmarczak/http-timer/dist/source/index.js:43:20)
at Socket.socketErrorListener (_http_client.js:475:9)
at Socket.emit (events.js:400:28)
at Socket.emit (domain.js:475:12)
at emitErrorNT (internal/streams/destroy.js:106:8)
at emitErrorCloseNT (internal/streams/destroy.js:74:3)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1159:16)
(node:76702) UnhandledPromiseRejectionWarning: Error: Failed to create session.
Unable to connect to "http://127.0.0.1:4723/", make sure browser driver is running on that address.
If you use services like chromedriver see initialiseServices logs above or in wdio.log file as the service might had problems to start the driver.
at startWebDriverSession (/Users/harsha.sharmagelato.com/Dev/work/repos/gelato-api-mobile/integration-tests/node_modules/webdriver/build/utils.js:72:15)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async Function.newSession (/Users/harsha.sharmagelato.com/Dev/work/repos/gelato-api-mobile/integration-tests/node_modules/webdriver/build/index.js:46:45)
at async Object.remote (/Users/harsha.sharmagelato.com/Dev/work/repos/gelato-api-mobile/integration-tests/node_modules/webdriverio/build/index.js:77:22)
at async /Users/harsha.sharmagelato.com/Dev/work/repos/gelato-api-mobile/integration-tests/src/stepDefinitions/test.js:30:20
(Use `node --trace-warnings ...` to show where the warning was created)
(node:76702) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:76702) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Any idea what is missing here?