WebDriverIO - Write Your First Script | Element APIs | click, sendKeys and getText - Part -3
Vložit
- čas přidán 23. 08. 2024
- #webdriverio #nodejs #javascript #automation
In this video, I have explained how to write test script in WebDriverIO.
Learn:
- how to use getText(), sendKeys() and click() methods
- how to run test
~~~Subscribe to this channel, and press bell icon to get some interesting videos on Selenium and Automation:
www.youtube.co...
Follow me on my Facebook Page:
/ naveenqtpexpert
Let's join our Automation community for some amazing knowledge sharing and group discussion on Telegram:
t.me/joinchat/...
Paid courses (Recorded) videos:
Java & Selenium Course: www.naveenautom...
API Course: www.naveenautom...
Please add this line in your package.json file, if you getting any error like: browser is not defined or no tests found.
"scripts": {
"test": "node ./node_modules/.bin/wdio ./wdio.conf.js"
},
It still does not work, I tried
"test": "./node_modules/.bin/wdio wdio.conf.js"
it worked.
@@avishekbehera Hi Avishek. I changed as per your suggestion but it is still giving me below error. Please help.
> webdriverio-mocha@1.0.0 test C:\Users\TailorJ\Downloads\WebDriverIO-Mocha
> wdio wdio.conf.js
Execution of 1 spec files started at 2020-02-26T08:26:19.326Z
2020-02-26T08:26:19.739Z INFO @wdio/cli:launcher: Run onPrepare hook
Starting ChromeDriver 80.0.3987.16 (320f6526c1632ad4f205ebce69b99a062ed78647-refs/branch-heads/3987@{#185}) on port 4444
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
2020-02-26T08:27:42.217Z ERROR @wdio/cli:utils: A service failed in the 'onPrepare' hook
Error: Unable to connect to selenium
at Timeout.hasStarted [as _onTimeout] (C:\Users\TailorJ\Downloads\WebDriverIO-Mocha
ode_modules\selenium-standalone\lib\check-started.js:17:10)
at listOnTimeout (internal/timers.js:549:17)
at processTimers (internal/timers.js:492:7)
@@jigartailor3755 Hi , were you able to fix it?
Hi Naveen,
I tried adding same, and even some suggested to not select HTML report, still i am getting same issue:
I tried uninstalling HTML report, but still i am getting below error:
C:\Users\Praveen\WebDriverPractice
ode_modules\.bin\wdio:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
^^^^^^^
SyntaxError: missing ) after argument list
←[90m at wrapSafe (internal/modules/cjs/loader.js:1070:16)←[39m
←[90m at Module._compile (internal/modules/cjs/loader.js:1120:27)←[39m
←[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)←[39m
@@praveenhalhalli4794 try commenting line //reporters: ['spec',['allure', {outputDir: 'allure-results'}],'html'], in wdio.conf,js
it worked for me
Just wanted to take ur time in ur busy schedule to inform you that I have 2 offers
I was New to automation. However I just followed ur videos delicately for 3 months and cracked the interviews successfully.
Thanks for your guidance Naveen and stay blessed always!
But this is not the end. We r always learning at every phase
Thanks again
Congratulations Supriya. Keep it up.
@supriya, could you help me how did you resolve the issue for . " ReferenceError: browser is not defined" error ?
Got the solution, we need to replace below lines in package.json file.
"scripts": {
"test": "./node_modules/.bin/wdio wdio.conf.js"
},
it should work.
@@alokshrivastava5476 Thanks it worked.
@@alokshrivastava5476 Hi Alok. I change as per your suggestion but it is still giving me an error. Please help.
> webdriverio-mocha@1.0.0 test C:\Users\TailorJ\Downloads\WebDriverIO-Mocha
> wdio wdio.conf.js
Execution of 1 spec files started at 2020-02-26T08:26:19.326Z
2020-02-26T08:26:19.739Z INFO @wdio/cli:launcher: Run onPrepare hook
Starting ChromeDriver 80.0.3987.16 (320f6526c1632ad4f205ebce69b99a062ed78647-refs/branch-heads/3987@{#185}) on port 4444
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
2020-02-26T08:27:42.217Z ERROR @wdio/cli:utils: A service failed in the 'onPrepare' hook
Error: Unable to connect to selenium
at Timeout.hasStarted [as _onTimeout] (C:\Users\TailorJ\Downloads\WebDriverIO-Mocha
ode_modules\selenium-standalone\lib\check-started.js:17:10)
at listOnTimeout (internal/timers.js:549:17)
at processTimers (internal/timers.js:492:7)
Waiting for this. Kudos to your dedication Naveen. Soon to be 100K
Awesome as always 👍😊
Guys, no need to create your project again if you added html report, just remove from packag.json and wdio.conf.js both files it will work.... Also html report project is a fork of wdio-html-format-reporter, That project has not been updated and doesnt work with the latest webdriverio 5.x.
Awesome! Your videos are very informative and useful for the entire testers community. I am having following issue.
"Appium exited before timeout.exit code : null." How to fix this error? Can I have the solution? I increased the timeouts also, but still it exists.
Nodejs version : 20.3.1
Wdio version : 8.36.1
Appium version : 2.5.4
Hi, this is something I'm getting when trying to launch the browser
Hi @Naveen Automation Labs why do we not explicitly close the browser in the JavaScript test?
How does the browser gets closed in the test? I wanted to know the flow please?
Naveen take some rest..You are continuous working 😃
Thanks Naveen for starting this tutorial.
I am following the steps as mentioned by you in comments and video.
Initially some failures were there, needed some changes, it's working now.
One question in terms of mocha framework and configuration.
I can see in my package.json, mocha framework being downloaded as well as under node_modules.
In wdio config file also, framework: mocha is present;
But when I am trying to write my test cases, describe/it and other pre-defined Mocha framework settings are not being displayed automatically; Assuming some problem in setup, can you please suggest?
Sample section of devDependencies:
"devDependencies": {
"@rpii/wdio-html-reporter": "^0.8.6",
"@wdio/allure-reporter": "^5.18.6",
"@wdio/local-runner": "^5.18.7",
"@wdio/mocha-framework": "^5.18.7",
"@wdio/selenium-standalone-service": "^5.16.10",
"@wdio/spec-reporter": "^5.18.7",
"@wdio/sync": "^5.18.7",
"chai": "^4.2.0",
"chai-webdriverio": "^1.0.0",
"local-runner": "^0.1.1-alpha",
"wdio-chromedriver-service": "^5.0.2",
"webdriverio": "^5.18.7"
},
Hi Naveen i am getting below error when i try to run test.
ERROR @wdio/local-runner: Failed launching test session: Error: Couldn't find plugin "html" reporter, neither as wdio scoped package "@wdio/html-reporter" nor as community package "wdio-html-reporter". Please make sure you have it installed!
at initialisePlugin (/Users/sriramku/Documents/webdriver-io-practice/node_modules/@wdio/utils/build/initialisePlugin.js:32:9)
at BaseReporter.initReporter (/Users/sriramku/Documents/webdriver-io-practice/node_modules/@wdio/runner/build/reporter.js:120:51)
at Array.map ()
at new BaseReporter (/Users/sriramku/Documents/webdriver-io-practice/node_modules/@wdio/runner/build/reporter.js:32:39)
at Runner.run (/Users/sriramku/Documents/webdriver-io-practice/node_modules/@wdio/runner/build/index.js:76:21)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
[0-0] FAILED
2020-04-12T10:56:26.463Z INFO @wdio/cli:launcher: Run onComplete hook
Spec Files: 0 passed, 1 failed, 1 total (100% completed) in 00:00:00
same error. i'm also getting
@@MrVinomaster any solution for this
Hi Naveen, how to send webdriverio project to new joiner in our organisation. Lets assume he has new laptop and nothing is installed in it. is there any quick way to have him start his work by avoiding all the initial setup in his lapy. Thanks in advance!
Hi Naveen,
Could u please explain y did u use "#" for first element and y not later.
And one more thing where did u use xpath, tagName and css..
Hope u will reply Soo 😊
#is used with ID in CssSelector. You can use tagname also directly without #. Keep watching upcoming videos, you will get to know.
@@naveenautomationlabs Thank you Naveen for your guidance not only I am a regular watcher but also I share and suggest my friends for your channel. As promised hope you will start protractor tutorial also,for which I am eagerly waiting. 😊
Hi Naveen, I have one scenario to right click on element then select option in webdriverio. Could you please help if any solution.
Nice 👍🏻
@Naveen AutomationLabs I am facing an issue like 9 vulnerabilities required manual review and could not be updated when i try to run the local-runner how to fix this issue ------ npm install local-runner --save-dev
Hello. Is there any way to hande Chrome Print Preview?? I wanted to close the print preview that appears during a run.
Hi naveen,
How to Automate the download and cancel using webdriverio and how we can assert the downloaded file name.
@Hi Naveen, I am getting error as 'no such element found', Please see the below error message.f4a47
[0-0] 2022-12-19T03:42:26.758Z INFO webdriver: RESULT {
[0-0] error: 'no such element',
[0-0] message: 'no such element: Unable to locate element: {"method":"css selector","selector":"#support-search-input"}
' +. Could you please help me to resolve this issue? Thanks
Hi Naveen , Could you please tell me ,
My test is running but that IT block statement is not showing in console but test is getting passed
Hello Naveen, I am facing this Error - like setValue is not a function ====>>> [0-0] TypeError in "Interaction with web elements Enter Value in a field"
TypeError: $(...).setValue is not a function
at Context. (/Users/rajib/Desktop/webDriverIO All/test/element.js:8:34)
at Context.executeAsync (/Users/rajib/Desktop/webDriverIO All/node_modules/@wdio/utils/build/shim.js:136:25)
at Context.testFrameworkFnWrapper (/Users/rajib/Desktop/webDriverIO All/node_modules/@wdio/utils/build/test-framework/testFnWrapper.js:45:32)
Hi Naveen, I am new to ur courses and found them so helpful, I am doing ur webdriverios training and getting an error while running first basic test. the error is below, can u help me about the error below how to resolve it:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! webdriverioframework@1.0.0
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the webdriverioframework@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
After my browser launches, it is not taking URL and close browser immediately. Kindly help me on this.
Hi Naveen - please help me to resolve the below error -
'node_modules' is not recognized as an internal or external command,
Package.json_
"scripts": {
"test": "node_modules/.bin/wdio ./wdio.conf.js"
}
Hi Naveen, I am trying this node ./node_modules/.bin/wdio ./wdio.conf.js" but still getting error. Please suggest
Can we execute it without standalone server ? - how we execute with local chromedriver in java.
Hi Naveen I could not launch browser . it gives filename or directory name or volume level syntax is incorrect
how can i solve this error
please help me
I am getting this error, not sure how to fix it, already added "test": "node ./node_modules/.bin/wdio ./wdio.conf.js" to the package.json
PS C:\Users\achawla\Documents\Webdriver-io-practice\test> npm run element
Debugger attached.
npm ERR! Missing script: "element"
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR! npm run
How to switch to incognito window from normal window in selenium?? ,please suggest
Hi Naveen,
How to find an element by xpath?I am getting error when I tried using xpath
how to keep browser open after the test has finished(both pass or fail) this is giving hard time as browser is closing as soon as the prog is executed.
Hi Naveen , , After configuring WebdrverIO(using Visual VS code V1.67.0 with Node.js V18.0 ) in windows 10 in hp laptop , I am getting following error while running through Chrome driver:: ERROR @wdio/runner: Error: write EPROTO 085C0000:error:0A000152:SSL routines:final_renegotiate:unsafe legacy renegotiation disabled:c:\ws\deps\openssl\openssl\ssl\statem\extensions.c:922:
Hi Naveen,
I have done the entire setup as per your suggestion and could observe that test case is being skipped while running the command npm run test
The error is as mentioned below:
ChromeDriver was started successfully.
2021-04-11T16:49:43.454Z INFO @wdio/cli:launcher: Run onWorkerStart hook
2021-04-11T16:49:43.466Z INFO @wdio/local-runner: Start worker 0-0 with arg: ./wdio.conf.js
[0-0] 2021-04-11T16:49:46.915Z INFO @wdio/local-runner: Run worker command: run
2021-04-11T16:49:48.528Z INFO @wdio/cli: [0-0] SKIPPED in chrome - C:\Users\Ravi\Documents\webdriverio-practise\test\element.js
2021-04-11T16:49:48.531Z INFO @wdio/cli:launcher: Run onComplete hook
Spec Files: 0 passed, 1 skipped, 1 total (100% completed) in 00:00:05
2021-04-11T16:49:48.536Z INFO @wdio/local-runner: Shutting down spawned worker
2021-04-11T16:49:48.791Z INFO @wdio/local-runner: Waiting for 0 to shut down gracefully
2021-04-11T16:49:48.795Z INFO @wdio/local-runner: shutting down
Can you please help in understanding why the test case is being skipped
Hi Naveen... Thanks for sharing knowledge
I just followed part 2 & part 3 while executing scripts I am getting following error
ReferenceError: browser is not defined
at Context. (test\element.js:12:20)
at processImmediate (internal/timers.js:439:21)
Could you please help on this?
I was about to message about the same problem. Some of the configuration is missing between part 2 and part 3
Please add this line in your package.json file.
"scripts": {
"test": "node ./node_modules/.bin/wdio ./wdio.conf.js"
},
Hello Learners, issue of "basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")" is fixed. from package.json file remove the -*-node-*- word from the beginning of the path like-
"scripts": {
"test": *"./node_modules/.bin/wdio ./wdio.conf.js"*
}
I hope this helps.
Cheers, Arvind
Tried this one and it worked buddy
"scripts": {
"test": "npx wdio run ./wdio.conf.js"
},
I am getting error while using getText function as.. "TypeError: label.getText is not a function"... please help.
I have solved the issue by adding yarn and sync. To do so enter below command in the terminal
npm install -g yarn
yarn add @wdio/sync
Hi Naveeen i am getting error Error: no test specified"
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! yes@1.0.0 test: `echo "Error: no test specified" && exit 1`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the yes@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\murali\AppData\Roaming
pm-cache\_logs\2020-04-18T06_52_57_833Z-debug.log
Hi Naveen,
For me it is not showing in console like how many it block passes in one specs. Its for me showing like this
0-0] PASSED in chrome - C:\Users\S900226\OneDrive - emiratesgroup\WebDriver.io\webdriverIOTutorial\test\element.js
2020-06-18T23:42:02.825Z INFO @wdio/cli:launcher: Run onComplete hook
Spec Files: 1 passed, 1 total (100% completed) in 00:00:52
Could you please check why this is happening?
how to write function to select specific radio group element using pageobject model in webdriverio
I Am Unable To See Browser Option At All In Drop Down
describe("test",function()
{
it("enter",function(){
brow
}):
});
,Any One Facing The Same Issue ?? I Installed All Drivers As Per The Instruction Given In Video ,I Am Able To See Browser Option If Select "TypeScript" Compiler But If I Select "Babel" or "No" Option From Compiler I Am Unable To See The Browser Option. Can Anyone Help
Hi Naveen,
I've followed all your configuration steps. And I'm getting the below error:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! webdriver-io-workspace@1.0.0 test: `wdio ./wdio.conf.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the webdriver-io-workspace@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\xxxx\AppData\Roaming
pm-cache\_logs\2020-06-02T11_26_26_315Z-debug.log
Hi Naveen, thanks for starting this series. while running the script i am getting the this error :
Starting ChromeDriver 80.0.3987.16 (320f6526c1632ad4f205ebce69b99a062ed78647-refs/branch-heads/3987@{#185}) on port 4444
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
ERROR @wdio/cli:utils: A service failed in the 'onPrepare' hook
Error: Unable to connect to selenium
I am getting same error, did you find a way to fix it?
Please add this line in your package.json file.
"scripts": {
"test": "node ./node_modules/.bin/wdio ./wdio.conf.js"
},
@@naveenautomationlabs hi naveen still after creating new tests still I am getting the error :-
Execution of 1 spec files started at 2020-02-25T12:52:42.393Z
2020-02-25T12:52:42.529Z INFO @wdio/cli:launcher: Run onPrepare hook
Starting ChromeDriver 80.0.3987.16 (320f6526c1632ad4f205ebce69b99a062ed78647-refs/branch-heads/3987@{#185}) on port 4444
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
2020-02-25T12:53:48.453Z ERROR @wdio/cli:utils: A service failed in the 'onPrepare' hook
Error: Unable to connect to selenium
at Timeout.hasStarted [as _onTimeout] (E:\Jiten newPractice\WebDriverIOScripts
ode_modules\selenium-standalone\lib\check-started.js:17:10)
at listOnTimeout (internal/timers.js:549:17)
at processTimers (internal/timers.js:492:7)
Continue...
2020-02-25T12:53:48.518Z INFO @wdio/local-runner: Start worker 0-0 with arg: wdio.conf.js
[0-0] 2020-02-25T12:53:49.121Z INFO @wdio/local-runner: Run worker command: run
[0-0] 2020-02-25T12:53:49.284Z ERROR @wdio/local-runner: Failed launching test session: Error: Couldn't find plugin "html" reporter, neither as wdio scoped package "@wdio/html-reporter" nor as community package "wdio-html-reporter". Please make sure you have it installed!
at initialisePlugin (E:\Jiten newPractice\WebDriverIOScripts
ode_modules\@wdio\utils\build\initialisePlugin.js:32:9)
at BaseReporter.initReporter (E:\Jiten newPractice\WebDriverIOScripts
ode_modules\@wdio
unner\build
eporter.js:120:51)
at Array.map ()
at new BaseReporter (E:\Jiten newPractice\WebDriverIOScripts
ode_modules\@wdio
unner\build
eporter.js:32:39)
at Runner.run (E:\Jiten newPractice\WebDriverIOScripts
ode_modules\@wdio
unner\build\index.js:77:21)
at process. (E:\Jiten newPractice\WebDriverIOScripts
ode_modules\@wdio\local-runner\build
un.js:37:20)
at process.emit (events.js:323:22)
at process.EventEmitter.emit (domain.js:482:12)
at emit (internal/child_process.js:876:12)
at processTicksAndRejections (internal/process/task_queues.js:85:21)
[0-0] FAILED
2020-02-25T12:53:49.316Z INFO @wdio/cli:launcher: Run onComplete hook
Spec Files: 0 passed, 1 failed, 1 total (100% completed) in 00:01:06
2020-02-25T12:53:49.367Z INFO @wdio/local-runner: Shutting down spawned worker
2020-02-25T12:53:49.659Z INFO @wdio/local-runner: Waiting for 0 to shut down gracefully
2020-02-25T12:53:49.662Z INFO @wdio/local-runner: shutting down
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! webdriverioscripts@1.0.0 test: `wdio wdio.conf.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the webdriverioscripts@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\ACER\AppData\Roaming
pm-cache\_logs\2020-02-25T12_53_49_738Z-debug.log
@@JitendraKumar-lr3vq Did u find solution for the above issue. I am also facing the same issue. Can please help me with it.
@@Kawali1000 no gopal m still struggling to fix this issue..
Hi @Naveen automation labs.
Following every step, when I am finally running the 'npm run test'
I am getting below error,
--------------------------------------------
PS C:\Users\sinlop\webdriver-io-practice> npm run test
> webdriver-io-practice@1.0.0 test C:\Users\sinlop\webdriver-io-practice
> echo "Error: no test specified" && exit 1
"Error: no test specified"
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! webdriver-io-practice@1.0.0 test: `echo "Error: no test specified" && exit 1`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the webdriver-io-practice@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\sinlop\AppData\Roaming
pm-cache\_logs\2021-06-14T11_27_18_175Z-debug.log
----------------------------------------------------------
could you please help, this project is important to me.
Got it solved. Replaced inside script.
"test": "wdio wdio.conf.js".
It worked and commented the "reporter:" in wdio.conf
Hi, can anyone please let me know how come method such as setValue() or getText() or url() does not get showed up automatically after "." while writing script
Can I directly start writing script if I don't I have that much knowledge of javascript?
you can but have some basic idea of JS first.
Hi Naveen - I am getting this error - test: `echo "Error: no test specified" && exit 1`
npm ERR! Exit status 1
.
Please advise. Thanks.
@ kpmanicka hi I m also getting same error can you plz guide me what you have done to fix it.
Naveen when I execute the 'npm run test' command after following all the steps in the part-2 video I am getting "ReferenceError: browser is not defined" . I noticed another person in the comments has also got the same issue. I followed all the steps
Please add this line in your package.json file.
"scripts": {
"test": "node ./node_modules/.bin/wdio ./wdio.conf.js"
},
Naveen AutomationLabs Thank you Naveen I will try that out
@@naveenautomationlabs Hi Naveen I had tried this and still, it's not working
any suggestion
TypeError: searchbar.setValue is not a function in wdio v 7 abvoe
iam facing above this issue can you help me naveen how i can resolve it
Hey is this issue resolved m getting similar issue
Hey Naveen my selenium server is not running and also the field is not accepting the input.
Hey did you figure the solution.?
Yes
Hi naveen i am getting this error
C:\Users\aphay\OneDrive\Documents\WebDriver-io-Practice
ode_modules\.bin\wdio:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
^^^^^^^
SyntaxError: missing ) after argument list
at Object.compileFunction (node:vm:360:18)
t wrapSafe (node:internal/modules/cjs/loader:1088:15)
at Module._compile (node:internal/modules/cjs/loader:1123:27)......
Can u plz help me how do i resolve this issue?????
Guys any one pls tell me whether node js will run in Internet explorer browser.
i want to know how to configure ie driver in webdriverio can u please help me
Hi Naveen,
I am getting an "error: setValue is not a function" when I am trying to execute the code you provided in the above video.
Hi, I am also facing the same issue. Did you found any solution for this?
@@Vinni-Dhruva I am facing the same issue --->>>> [0-0] TypeError in "Interaction with web elements Enter Value in a field"
TypeError: $(...).setValue is not a function
at Context. (/Users/rajib/Desktop/webDriverIO All/test/element.js:8:34)
at Context.executeAsync (/Users/rajib/Desktop/webDriverIO All/node_modules/@wdio/utils/build/shim.js:136:25)
at Context.testFrameworkFnWrapper (/Users/rajib/Desktop/webDriverIO All/node_modules/@wdio/utils/build/test-framework/testFnWrapper.js:45:32). ----->>> is there any solution for that ?
Naveen , can you please suggest!!!'
@@aarbie1981 Hi i am getting the same error for Click function. Did you find any solution for this ?
I am also facing the same issue, tried with setValue(), addValue() & getText()...none of them are working. Please suggest on this.
Hi Naveen, I am getting the following error while trying to run the test. " ReferenceError: browser is not defined"
did you get any resolution for this ? even i am getting this error.
@@alokshrivastava5476 same issue
@@giridhartupuri7273 its working for me now, have replaced below lines in package.json
"scripts": {
"test": "./node_modules/.bin/wdio wdio.conf.js"
},
@@alokshrivastava5476 r u executing in windows ?
Iam getting this error, Please help me
npm ERR! path D:\JavaScript_workspace\package.json
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open 'D:\JavaScript_workspace\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
How to run single test file in webdriverio?
Hi Naveen/ Group, Please help with Error - I am getting error :-
0 passing (16ms)
1 failing
1) interaction with web element
enter value in a field:
ReferenceError: browser is not defined
at Context. (test\element.js:5:9)
at processImmediate (internal/timers.js:456:21)
This is my package.json
{
"name": "webdriver-io-practice",
"version": "1.0.0",
"description": "this is webdriver io scripts",
"main": "index.js",
"scripts":
{
"test": "mocha"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@rpii/wdio-html-reporter": "^6.0.1",
"@wdio/allure-reporter": "^6.0.14",
"@wdio/local-runner": "^6.0.15",
"@wdio/mocha-framework": "^6.0.15",
"@wdio/spec-reporter": "^6.0.14",
"@wdio/sync": "^6.0.15",
"chai": "^4.2.0",
"chai-webdriverio": "^1.0.0",
"chromedriver": "^81.0.0",
"local-runner": "^0.1.1-alpha",
"wdio-chromedriver-service": "^6.0.1",
"webdriverio": "^6.0.15"
},
"dependencies":
{
"@wdio/cli": "^6.0.15"
}
}
Try updating the section 'scripts { "test" : }
with the folder location where your test scripts are kept like ./test/**/*.js.
Second- are you able to run sample tets case like opening a url kind of ?
Hi can you please add WebDriver IO with cucumber series
Hello guys,
Did anyone go the below error?
INFO @wdio/local-runner: Run worker command: run
[0-0] 2020-03-12T21:22:04.849Z ERROR @wdio/local-runner: Failed launching test session: TypeError: ReporterClass is not a constructor
at BaseReporter.initReporter (C:\MyWork@Merilytics\webDriver-IO-Scripts
ode_modules\@wdio
unner\build
eporter.js:124:14)
at Array.map ()
@wdio/local-runner: Failed launching test session: Error: Couldn't find plugin "html" reporter, neither as wdio scoped package "@wdio/html-reporter" nor as community package "wdio-html-reporter". Please make sure you have it installed!
at initialisePlugin (C:\Users\uspat\OneDrive\Documents\Webdriver.IO Projects\HOC-Automation
ode_modules\@wdio\utils\build\initialisePlugin.js:32:9)
at BaseReporter.initReporter (C:\Users\uspat\OneDrive\Documents\Webdriver.IO Projects\HOC-Automation
ode_modules\@wdio
unner\build
eporter.js:120:51)
at Array.map ()
at new BaseReporter (C:\Users\uspat\OneDrive\Documents\Webdriver.IO Projects\HOC-Automation
ode_modules\@wdio
unner\build
eporter.js:32:39)
at Runner.run (C:\Users\uspat\OneDrive\Documents\Webdriver.IO Projects\HOC-Automation
ode_modules\@wdio
unner\build\index.js:77:21)
at process. (C:\Users\uspat\OneDrive\Documents\Webdriver.IO Projects\HOC-Automation
ode_modules\@wdio\local-runner\build
un.js:37:20)
at process.emit (events.js:323:22)
at process.EventEmitter.emit (domain.js:482:12)
at emit (internal/child_process.js:876:12)
at processTicksAndRejections (internal/process/task_queues.js:85:21)
[0-0] FAILED
I have followed the exact steps
This is the error i am getting did u find any sollution uday
remove the wdio-html-reporter from devDependecies and wdio.conf.js, after removing i was able to run test
Hi Navenn , How to identity stand alone server path in our local machie and where i have to execute the below command :
java -jar selenium-server-standalone-3.141.59.jar -port 4545
download this jar file and put it in ur directory in C drive. and start the server using java -jar selenium-server-standalone-3.141.59.jar -port 4545
Hi Naveen
am getting below error while running the test in mocha framework
WARN @wdio/mocha-framework: Unable to load spec files quite likely because they rely on `browser` object that is not fully initialised.
`browser` object has only `capabilities` and some flags like `isMobile`.
Helper files that use other `browser` commands have to be moved to `before` hook
can you help me sort out this
I am facing issue after running command npm test run
>webdriver-io-practise@1.0.0 test c:\\ path of document.
>echo: "Error: no test specified" && exit 1"run"
"Error: no test specified"
npm ERR! Test Failed.
Can any one suggest on this ?
Please add this line in your package.json file.
"scripts": {
"test": "node ./node_modules/.bin/wdio ./wdio.conf.js"
},
@@naveenautomationlabs implemented the above line.
But facing a new issue now. PFB error.
webdriver-io-practice@1.0.0 test C: \Users Administrator Documents webdriver-io-practice
> node ./node_modules/.bin/wdio .wdio.conf.js
C:\Users Administrator\Documents Webdriverio-practice
ode_modules\bin\wdio:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
SyntaxError: missing ) after argument list
at Module._compile (internal/modules/cjs/loader.js:991:10)
at object.module._extensions..js (internal/modules/cjs/loader.js:991:10)
at Module.load (internal/modules/cjs/loader.js:811:32)
at Function.Module._load (internal/modules/cjs/loader.js:723:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1043: 20)
at internal/main/run_main_module.js:17:11
npm ERR! code ELIFECYCLE
errno 1
webdriver-io-practice@1.0.0 test: "node ./node_modules/.bin/wdio ./wdio.conf.js
ERR! Exit status 1
npm ERR!
npm ERA! Failed at the webdriver-io-practice@1.0.0 test script.
Npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Any updates Naveen, after your solution, still m getting error
@@naveenautomationlabs hi naveen me also facing the same issue even after adding the scripts line at the package.json file ..could you please help ..
by adding this will solve the following error - "scripts": {
"test": "./node_modules/.bin/wdio wdio.conf.js"
},
Hi Naveen
I am also getting the same issue after running command "npm run test"
> webdriver-io@1.0.0 test d:\WebDriver-IO
> echo "Error: no test specified" && exit 1
"Error: no test specified"
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! webdriver-io@1.0.0 test: `echo "Error: no test specified" && exit 1`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the webdriver-io@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\inspiron\AppData\Roaming
pm-cache\_logs\2020-03-14T14_34_52_484Z-debug.log
Please help!!
Show me ur package.json file
@@naveenautomationlabs {
"name": "webdriver-io",
"version": "1.0.0",
"description": "This is npm wedriverio script",
"main": "index.js",
"scripts": {
"test": "./node_modules/.bin/wdio wdio.conf.js"
},
"author": "Akanksha Sharma",
"license": "ISC",
"devDependencies": {
"@rpii/wdio-html-reporter": "^0.8.6",
"@wdio/allure-reporter": "^5.18.6",
"@wdio/local-runner": "^5.21.0",
"@wdio/mocha-framework": "^5.18.7",
"@wdio/spec-reporter": "^5.18.7",
"@wdio/sync": "^5.20.1",
"chai": "^4.2.0",
"chai-webdriverio": "^1.0.0",
"chromedriver": "^80.0.1",
"local-runner": "^0.1.1-alpha",
"wdio-chromedriver-service": "^5.0.2",
"wdio-cucumber-reporter": "0.0.2",
"webdriverio": "^5.21.0"
},
"dependencies": {
"@wdio/cli": "^5.21.0"
}
}
Now getting this error
Execution of 1 spec files started at 2020-03-14T16:23:18.964Z
2020-03-14T16:23:19.096Z INFO @wdio/cli:launcher: Run onPrepare hook
Starting ChromeDriver 80.0.3987.16 (320f6526c1632ad4f205ebce69b99a062ed78647-refs/branch-heads/3987@{#185}) on port 4444
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
2020-03-14T16:23:19.644Z INFO @wdio/local-runner: Start worker 0-0 with arg: wdio.conf.js
[0-0] 2020-03-14T16:23:20.944Z INFO @wdio/local-runner: Run worker command: run
[0-0] 2020-03-14T16:23:21.282Z ERROR @wdio/local-runner: Failed launching test session: Error: Couldn't find plugin "html" reporter,
neither as wdio scoped package "@wdio/html-reporter" nor as community package "wdio-html-reporter". Please make sure you have it installed!
at initialisePlugin (d:\WebDriver-IO
ode_modules\@wdio\utils\build\initialisePlugin.js:32:9)
at BaseReporter.initReporter (d:\WebDriver-IO
ode_modules\@wdio
unner\build
eporter.js:120:51)
at Array.map ()
at new BaseReporter (d:\WebDriver-IO
Fixed the above issues but now getting this
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
^^^^^^^
SyntaxError: missing ) after argument list
at new Script (vm.js:83:7)
at createScript (vm.js:267:10)
at Object.runInThisContext (vm.js:319:10)
at Module._compile (internal/modules/cjs/loader.js:685:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:733:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:775:12)
at startup (internal/bootstrap/node.js:300:19)
@@kreativevideos786 - Did u find out the solution? i am also facing same issue.
CAUTION
I was getting an issue with chrome session id, following the threads on stackoverflow led me to this:'As of 14/04/2021 sync mode will not be supported anymore starting from Node.js v16 due to changes in Chromium. If you start a project with WebdriverIO we recommend to not use sync mode anymore.'
An update to this video is required perhaps?
Hi Naveen,
I followed all the steps that you had mentioned in the video.
While running the test, google chrome was launched but then it gave the below error and chrome stopped later :
[0-0] TypeError: runnable.callback is not a function
[0-0] at process.emit (node:events:402:35)
[0-0] at process.emit (node:domain:475:12)
[0-0] at process._fatalException (node:internal/process/execution:164:25)
[0-0] FAILED in chrome - /test/element.js
2022-05-07T06:58:37.324Z INFO @wdio/cli:launcher: Run onWorkerEnd hook
2022-05-07T06:58:37.324Z INFO @wdio/cli:launcher: Run onComplete hook
2022-05-07T06:58:37.325Z INFO @wdio/selenium-standalone-service: shutting down all browsers
Spec Files: 0 passed, 1 failed, 1 total (100% completed) in 00:00:50
Can you help me with this, if I've missed something from my end ?
hopeless automation tool ever I came across
Hi @naveen
I am getting below error
I given "scripts": {
"test": "node ./node_modules/.bin/wdio ./wdio.conf.js",
"wdio": "wdio run ./wdio.conf.js"
},
still facing issue
G:\wdio-practice
ode_modules\.bin\wdio:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
^^^^^^^
SyntaxError: missing ) after argument list
at internalCompileFunction (node:internal/vm:73:18)
at wrapSafe (node:internal/modules/cjs/loader:1176:20)
at Module._compile (node:internal/modules/cjs/loader:1218:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Module._load (node:internal/modules/cjs/loader:958:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47
Hi Naveen,
I tried with all the below approaches and all the suggestions given by the community but still facing an issue in identifying an element in my case browser is launching and it's closing at the end but no interaction is getting performed on the browser.
Attaching the screen error for reference. If anyone of you had faced the same issue please let me know the resolution.
Thanks in advance
Code used:
describe("interaction with webelements", function(){
it("enter value in a field",function(){
browser.url('/');
browser.pause(5000);
const search = $('#twotabsearchtextbox');
console.log(search.gettext());
search.setValue('apple mac book');
browser.pause(5000);
});
});
Error Obtained:
TypeError in "interaction with webelements enter value in a field"
TypeError: search.gettext is not a function
at Context. (C:\Users\PETER\Documents\webdriver-io-practice\test\element.js:7:28)
at Context.executeAsync (C:\Users\PETER\Documents\webdriver-io-practice
ode_modules\@wdio\utils\build\shim.js:136:25)
at Context.testFrameworkFnWrapper (C:\Users\PETER\Documents\webdriver-io-practice
ode_modules\@wdio\utils\build\test-framework\testFnWrapper.js:45:32)
[0-0] 2021-05-06T14:53:14.957Z INFO webdriver: COMMAND deleteSession()
[0-0] 2021-05-06T14:53:14.957Z INFO webdriver: [DELETE] localhost:9515/session/ad027bdacca995b0ca52c013f4d7896f
[0-0] 2021-05-06T14:53:14.980Z INFO webdriver: RESULT {
[0-0] error: 'no such element',
[0-0] message: 'no such element: Unable to locate element: {"method":"css selector","selector":"#twotabsearchtextbox"}
' +
[0-0] ' (Session info: chrome=90.0.4430.93)',
[0-0] stacktrace: 'Backtrace:
' +
[0-0] '\tOrdinal0 [0x0061C013+2474003]
' +
[0-0] '\tOrdinal0 [0x005B29C1+2042305]
' +
[0-0] '\tOrdinal0 [0x004C2F68+1060712]
' +
[0-0] '\tOrdinal0 [0x004ED8A4+1235108]
' +
[0-0] '\tOrdinal0 [0x00517232+1405490]
' +
[0-0] '\tOrdinal0 [0x0050684A+1337418]
' +
[0-0] '\tOrdinal0 [0x005155CB+1398219]
' +
[0-0] '\tOrdinal0 [0x005066DB+1337051]
' +
[0-0] '\tOrdinal0 [0x004E3427+1192999]
' +
[0-0] '\tOrdinal0 [0x004E42EE+1196782]
' +
Hi Can anyone help me out on this I am stuck on this from past 1 week
how to fix this error {iNFO webdriver: RESULT { height: 989, width: 1920, x: 0, y: 27 }
[0-7] 2022-06-21T14:35:19.775Z ERROR @wdio/sync: ReferenceError: allure is not defined
[0-7] at Object.beforeSuite (/home/
anyone help for this my script is failed
Hi Naveen,
I am also trying the same but everytime getting an error like:
] 2022-11-26T07:28:43.482Z INFO webdriver: COMMAND findElement("css selector", "#twotabsearchtextbox")
[0-0] 2022-11-26T07:28:43.483Z INFO webdriver: [POST] localhost:9515/session/d018f36aeafd32fef028c34a468f202d/element
[0-0] 2022-11-26T07:28:43.483Z INFO webdriver: DATA { using: 'css selector', value: '#twotabsearchtextbox' }
[0-0] 2022-11-26T07:28:43.484Z INFO webdriver: COMMAND navigateTo("www.amazon.com/")
[0-0] 2022-11-26T07:28:43.484Z INFO webdriver: [POST] localhost:9515/session/d018f36aeafd32fef028c34a468f202d/url
[0-0] 2022-11-26T07:28:43.484Z INFO webdriver: DATA { url: 'www.amazon.com/' }
[0-0] 2022-11-26T07:28:43.486Z INFO webdriver: COMMAND deleteSession()
[0-0] 2022-11-26T07:28:43.486Z INFO webdriver: [DELETE] localhost:9515/session/d018f36aeafd32fef028c34a468f202d
[0-0] 2022-11-26T07:28:45.242Z INFO webdriver: RESULT {
[0-0] error: 'no such element',
[0-0] message: 'no such element: Unable to locate element: {"method":"css selector","selector":"#twotabsearchtextbox"}
' +
[0-0] ' (Session info: chrome=107.0.5304.121)',
[0-0] stacktrace: '0 chromedriver
the xpath looks good to me can you please help me here what to do to resolve this: any help is much appreciated😊