Closed vagisha-nidhi195 closed 2 years ago
I would start by updating to a more recent version of WebdriverIO and Node to see if it resolves your issue. Version 5 is a couple years old and version 7 is the latest.
Tried updating the version. I am getting the following error. Tried the same thing with global $.
2022-02-19T09:18:35.889Z INFO @wdio/cli:launcher: Run onPrepare hook
2022-02-19T09:18:35.892Z INFO @wdio/cli:launcher: Run onWorkerStart hook
2022-02-19T09:18:35.893Z INFO @wdio/local-runner: Start worker 0-0 with arg:
[0-0] 2022-02-19T09:18:36.225Z INFO @wdio/local-runner: Run worker command: run
[0-0] 2022-02-19T09:18:36.365Z DEBUG @wdio/config:utils: Found 'ts-node' package, auto-compiling TypeScript files
[0-0] 2022-02-19T09:18:36.366Z DEBUG @wdio/local-runner:utils: init multiremote session
[0-0] (node:887) UnhandledPromiseRejectionWarning: TypeError: browser.$ is not a function
[0-0] at /Users/vagishn/WinAppDriver/Samples/JavaScript/packages/webdriverio/test/mochasample.ts:4:36
[0-0] at Generator.next (<anonymous>)
[0-0] at /Users/vagishn/WinAppDriver/Samples/JavaScript/packages/webdriverio/test/mochasample.ts:8:71
[0-0] at new Promise (<anonymous>)
[0-0] at __awaiter (/Users/vagishn/WinAppDriver/Samples/JavaScript/packages/webdriverio/test/mochasample.ts:4:12)
[0-0] at loginToWindowsPVApp (/Users/vagishn/WinAppDriver/Samples/JavaScript/packages/webdriverio/test/mochasample.ts:3:41)
[0-0] at Suite.<anonymous> (/Users/vagishn/WinAppDriver/Samples/JavaScript/packages/webdriverio/test/mochasample.ts:12:5)
[0-0] at Object.create (/Users/vagishn/WinAppDriver/Samples/JavaScript/packages/webdriverio/node_modules/mocha/lib/interfaces/common.js:148:19)
[0-0] at context.suite (/Users/vagishn/WinAppDriver/Samples/JavaScript/packages/webdriverio/node_modules/mocha/lib/interfaces/tdd.js:49:27)
[0-0] at Object.<anonymous> (/Users/vagishn/WinAppDriver/Samples/JavaScript/packages/webdriverio/test/mochasample.ts:11:1)
[0-0] (node:887) 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)
[0-0] (node:887) [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.
2022-02-19T09:18:36.742Z DEBUG @wdio/local-runner: Runner 0-0 finished with exit code 0
2022-02-19T09:18:36.743Z INFO @wdio/cli: [0-0] SKIPPED in MultiRemote - /test/mochasample.ts
2022-02-19T09:18:36.743Z INFO @wdio/cli:launcher: Run onComplete hook
My tsconfig file
{
"compilerOptions": {
"baseUrl": ".",
"target": "es6",
"module": "commonjs",
"jsx": "react",
"outDir": "dist",
"declaration": true,
"sourceMap": true,
"noEmitOnError": true,
"skipLibCheck": true,
"moduleResolution": "node",
"noEmit": false,
"noUnusedLocals": true,
"strict": true,
"rootDir": ".",
"esModuleInterop": true,
"types": [
"node",
"webdriverio/async",
"@wdio/mocha-framework"
]
},
"include": [
"pages",
"test",
"./**/*.ts"
],
"exclude": [
]
}
[0-0] 2022-02-19T09:18:36.366Z DEBUG @wdio/local-runner:utils: init multiremote session [0-0] (node:887) UnhandledPromiseRejectionWarning: TypeError: browser.$ is not a function
Are you sure you want to run a multiremote session? Can you provide a minimal reproducible example?
I am finally able to run commands when running mocha in bdd mode. Getting the same issue with tdd mode. Yes, I want to run in a multiremote session as I want to control the app as well as the windows 'root' desktop to manage some things.
Now the problem I am having is that the multi remote configuration is not running properly. I am running appium server on my remote machine.
Appium server logs: https://github.com/vagisha-nidhi195/demo-webdriverio-mocha/blob/master/src/appium_server_logs.txt Here are the logs
[0-0] RUNNING in MultiRemote - /dist/src/test/e2e/specs/Winapp.spec.js
[0-0] (node:38723) [DEP0016] DeprecationWarning: 'root' is deprecated, use 'global'
[0-0] unknown error in "Winapppppppp Winapp test"
unknown error: An unknown server-side error occurred while processing the command. Original error: 'POST /element' cannot be proxied to WinAppDriver server because its process is not running (probably crashed). Check the Appium log for more details
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at Array.map (<anonymous>)
at global.$ (/Users/vagishn/demo-webdriverio-mocha-master/node_modules/@wdio/runner/build/index.js:181:42)
at Context.<anonymous> (/Users/vagishn/demo-webdriverio-mocha-master/dist/src/test/e2e/specs/Winapp.spec.js:5:31)
at Context.executeAsync (/Users/vagishn/demo-webdriverio-mocha-master/node_modules/@wdio/utils/build/shim.js:137:25)
at Context.exports.testFrameworkFnWrapper (/Users/vagishn/demo-webdriverio-mocha-master/node_modules/@wdio/utils/build/test-framework/testFnWrapper.js:44:32)
Reproducible example: https://github.com/vagisha-nidhi195/demo-webdriverio-mocha/
npm run build
Thanks for providing a reproducible example. I don't have a Windows machine so I won't be able to look into this anytime soon by any hints that lead to the origin of this problem or PRs that solve it are highly appreciated. Cheers!
const login = async () => {
const element = await $('.//*//ComboBox')
element.click()
}
suite ('random test',async () => {
await login()
})
You should add await as the function is async one , u should suite async I believe
Thanks for investigating @praveendvd , I looked into the test case as well:
describe('Winapppppppp', () => {
before(() => {
});
it('Winapp test', async () => {
const element = await $('.//*//ComboBox')
element.click()
browser.pause(10000)
browser.refresh()
const pageSource = await browser.getPageSource()
console.log(pageSource)
const elem = await $('[name="United Kingdom"]')
elem.click()
});
});
As you pointed out async/await
is not used correctly, the correct way of writing the test would be:
describe('Winapppppppp', () => {
before(() => {
});
it('Winapp test', async () => {
const element = await $('.//*//ComboBox')
await element.click()
await browser.pause(10000)
await browser.refresh()
const pageSource = await browser.getPageSource()
console.log(pageSource)
const elem = await $('[name="United Kingdom"]')
await elem.click()
});
});
Closing the issue as it doesn't seem to be a problem with WebdriverIO.
Have you read the Contributing Guidelines on issues?
WebdriverIO Version
"^5.23.0"
Node.js Version
node@10
Mode
WDIO Testrunner
Which capabilities are you using?
What happened?
When I run the test using mocha framework, the wdio sends a DELETE session before any action is completed. I am using aync behaviour in my tests. I am running the test on a remote machine with winappdriver.exe running on the machine.
Searched this issue https://github.com/webdriverio/webdriverio/issues/4307 but I am not using sync behaviour in my tests.
What is your expected behavior?
Expected behaviour is that it should perform the actions before sending a delete session.
How to reproduce the bug.
To reproduce the bug create a mocha test file
Use the versions of packages as defined below: package.json file: I am not using the latest frameworks, as I need to integrate this with another package.
Connect to a machine running winppdriver.exe (or localhost) (Provide the ip address and port in services in wdio config file.
Run the test with wdio.
Relevant log output