Requirement: To get the message from the alert i.e. “Invalid username or password.”
This is the webview in my mobile application and I am trying to access the text using webdriverio but I am facing challenges to achieve it.
I tried:
const alertError = await browser.$(
.alert-error
);
console.log(alertError);
but this is giving me error:
[0-1] 2022-06-14T08:42:21.250Z INFO webdriver: COMMAND findElement(“css selector”, “.alert-error”)
[0-1] 2022-06-14T08:42:21.250Z INFO webdriver: [POST] http://localhost:4723/session/81fed723-acd7-4d28-97bd-e2caed0009e5/element
[0-1] 2022-06-14T08:42:21.250Z INFO webdriver: DATA { using: ‘css selector’, value: ‘.alert-error’ }
[0-1] 2022-06-14T08:42:21.590Z INFO webdriver: RESULT {
[0-1] error: ‘no such element’,
[0-1] message: ‘An element could not be located on the page using the given search parameters.’,
[0-1] stacktrace: ‘NoSuchElementError: An element could not be located on the page using the given search parameters.\n’ +
[0-1] ’ at AndroidUiautomator2Driver.findElOrEls (/Users/harsha.sharmagelato.com/Dev/work/repos/gelato-api-mobile/integration-tests/node_modules/appium/node_modules/appium-android-driver/lib/commands/find.js:75:11)\n’ +
[0-1] ’ at processTicksAndRejections (internal/process/task_queues.js:95:5)\n’ +
[0-1] ’ at AndroidUiautomator2Driver.findElOrElsWithProcessing (/Users/harsha.sharmagelato.com/Dev/work/repos/gelato-api-mobile/integration-tests/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/commands/find.js:33:12)\n’ +
[0-1] ’ at AndroidUiautomator2Driver.findElement (/Users/harsha.sharmagelato.com/Dev/work/repos/gelato-api-mobile/integration-tests/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/commands/find.js:53:10)’
[0-1] }
[0-1] Element {
[0-1] sessionId: ‘81fed723-acd7-4d28-97bd-e2caed0009e5’,
[0-1] error: {
[0-1] error: ‘no such element’,
[0-1] message: ‘An element could not be located on the page using the given search parameters.’,
[0-1] stacktrace: ‘NoSuchElementError: An element could not be located on the page using the given search parameters.\n’ +
[0-1] ’ at AndroidUiautomator2Driver.findElOrEls (/Users/harsha.sharmagelato.com/Dev/work/repos/gelato-api-mobile/integration-tests/node_modules/appium/node_modules/appium-android-driver/lib/commands/find.js:75:11)\n’ +
[0-1] ’ at processTicksAndRejections (internal/process/task_queues.js:95:5)\n’ +
[0-1] ’ at AndroidUiautomator2Driver.findElOrElsWithProcessing (/Users/harsha.sharmagelato.com/Dev/work/repos/gelato-api-mobile/integration-tests/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/commands/find.js:33:12)\n’ +
[0-1] ’ at AndroidUiautomator2Driver.findElement (/Users/harsha.sharmagelato.com/Dev/work/repos/gelato-api-mobile/integration-tests/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/commands/find.js:53:10)’
[0-1] },
[0-1] selector: ‘.alert-error’,
[0-1] parent: Browser {
[0-1] sessionId: ‘81fed723-acd7-4d28-97bd-e2caed0009e5’,
[0-1] capabilities: {
[0-1] platform: ‘LINUX’,
[0-1] webStorageEnabled: false,
[0-1] takesScreenshot: true,
[0-1] javascriptEnabled: true,
[0-1] databaseEnabled: false,
[0-1] networkConnectionEnabled: true,
[0-1] locationContextEnabled: false,
[0-1] warnings: {},
[0-1] desired: [Object],
[0-1] platformName: ‘Android’,
[0-1] noReset: false,
[0-1] fullReset: false,
[0-1] automationName: ‘uiautomator2’,
[0-1] deviceName: ‘emulator-5554’,
[0-1] platformVersion: ‘11’,
[0-1] app: ‘…/build/app/outputs/flutter-apk/app-stage-release.apk’,
[0-1] appWaitDuration: 20000,
[0-1] newCommandTimeout: 12000,
[0-1] webviewConnectTimeout: 20000,
[0-1] fullContextList: false,
[0-1] autoAcceptAlerts: true,
[0-1] chromedriverExecutable: ‘./node_modules/chromedriver/lib/chromedriver/chromedriver’,
[0-1] chromeOptions: [Object],
[0-1] deviceUDID: ‘emulator-5554’,
[0-1] appPackage: ‘com.gelato.api.stage’,
[0-1] deviceApiLevel: 30,
[0-1] deviceScreenSize: ‘1080x2340’,
[0-1] deviceScreenDensity: 440,
[0-1] deviceModel: ‘sdk_gphone_arm64’,
[0-1] deviceManufacturer: ‘Google’,
[0-1] pixelRatio: 2.75,
[0-1] statBarHeight: 66,
[0-1] viewportRect: [Object]
[0-1] },
[0-1] addCommand: [Function (anonymous)],
[0-1] overwriteCommand: [Function (anonymous)],
[0-1] addLocatorStrategy: [Function (anonymous)],
[0-1] config: {
[0-1] specs: [Array],
[0-1] suites: {},
[0-1] exclude: ,
[0-1] outputDir: undefined,
[0-1] logLevel: ‘trace’,
[0-1] logLevels: {},
[0-1] excludeDriverLogs: ,
[0-1] bail: 0,
[0-1] waitforInterval: 500,
[0-1] waitforTimeout: 10000,
[0-1] framework: ‘cucumber’,
[0-1] reporters: [Array],
[0-1] services: [Array],
[0-1] maxInstances: 10,
[0-1] maxInstancesPerCapability: 100,
[0-1] filesToWatch: ,
[0-1] connectionRetryTimeout: 500000,
[0-1] connectionRetryCount: 3,
[0-1] execArgv: ,
[0-1] runnerEnv: {},
[0-1] runner: ‘local’,
[0-1] specFileRetries: 0,
[0-1] specFileRetriesDelay: 0,
[0-1] specFileRetriesDeferred: false,
[0-1] reporterSyncInterval: 100,
[0-1] reporterSyncTimeout: 5000,
[0-1] cucumberFeaturesWithLineNumbers: ,
[0-1] autoCompileOpts: [Object],
[0-1] mochaOpts: [Object],
[0-1] jasmineOpts: [Object],
[0-1] cucumberOpts: [Object],
[0-1] onPrepare: ,
[0-1] onWorkerStart: ,
[0-1] onWorkerEnd: ,
[0-1] before: ,
[0-1] beforeSession: ,
[0-1] beforeSuite: ,
[0-1] beforeHook: ,
[0-1] beforeTest: ,
[0-1] beforeCommand: ,
[0-1] afterCommand: ,
[0-1] afterTest: ,
[0-1] afterHook: ,
[0-1] afterSuite: ,
[0-1] afterSession: ,
[0-1] after: [Array],
[0-1] onComplete: [Array],
[0-1] onReload: ,
[0-1] beforeFeature: ,
[0-1] beforeScenario: ,
[0-1] beforeStep: ,
[0-1] afterStep: [Array],
[0-1] afterScenario: ,
[0-1] afterFeature: ,
[0-1] baseUrl: ‘http://localhost’,
[0-1] appium: [Object],
[0-1] port: 4723,
[0-1] path: ‘/wd/hub’,
[0-1] _: [Array],
[0-1] ‘$0’: ‘/Users/harsha.sharmagelato.com/Dev/work/repos/gelato-api-mobile/integration-tests/node_modules/.bin/wdio’,
[0-1] ignoredWorkerServices:
[0-1] }
[0-1] },
[0-1] emit: [Function: bound ],
[0-1] isReactElement: false,
[0-1] addCommand: [Function (anonymous)],
[0-1] overwriteCommand: [Function (anonymous)]
[0-1] }
I don’t understand what I am missing at my end.
Any inputs will be appreciated. Thank you