If you use an arrow function in Hooks, the reason you get an error is because the arrow functions have their own lexical context and do not correctly determine the this context. Hooks use context significantly and this context must be set as expected by the hook function. Instead, you should use regular function definition in hooks instead of arrow function. Normal functions automatically get the context and this context is set correctly.
can you suggest changes if i have list of devices defined in playwright config ts file and want to use that instead of defining specific browsers in the hooks
I added code as you have instructed Kuoshik but when I run the test I get this error in hooks file - "SyntaxError: Cannot use import statement outside a module". The only difference is in my project application, they already have typescript and ts-loader installed. I am not sure if that would make the difference.
why is it like same things run in your device does not run in my device. like cucumber extension automatically take from feature to step function but it does not work in my system. Also this video's adding to cart using two users does not work.
Hi Koushik,, thanks for the videos. It's really helpful. I am seeing issue in navigating from features file to respective definitions when I using ctrl plus click. It doesn't show underscore in gwt on pressing ctrl button. What could be issue and how can I fix that?
Great tutorial. I am facing the below issue: 1. I copied the step definitions generated and pasted them. When I ran the command “npm run test” I am getting steps undefined? Could you please help me with the above issue?
@LetCode with Koushik When I am running with npm run test getting below issue. its not picking the scenarios. Also tried with your repo . its same issue 1 scenario (1 skipped) 2 steps (2 skipped) 0m00.003s (executing steps: 0m00.000s)
Hi, I am reciving this error : error TS2305: Module '"../../hooks/PageFixture"' has no exported member 'PageFixture'. 2 import { PageFixture } from "../../hooks/PageFixture";
Thanks it is very helpful. Can you please help how we can use soft assertion in playwright with cucumber Typescript. The existing playwright method .soft() is not working over cucumber framework.
Hi Kaushik, Previously I was facing "TypeError: Cannot read properties of undefined" for .locator then I have done all your mentioned changes in hooks and pageFixture files, it is working for .locator(pre-define) methods now, but when I am trying to call POM method in step def file, it is showing me that similar error "TypeError: Cannot read properties of undefined"(this is working fine for single feature file, but when I have created multiple feature files then it started showing mi this undefined error while accessing POM method)
@@letcode Yes, got it, Thank You. I have another question regarding maintenance, If there will be any major UI changes in future(and no unique locators currently) then will it be feasible to use your mentioned folder structure or should we use any other approach for script maintenance? Could you please suggest??
@@letcode Error: function uses multiple asynchronous interfaces: callback and promise to use the callback interface: do not return a promise to use the promise interface: remove the last argument to the function i am getting error.
Nice video! In every step defination file you are writing setDefaultTimeout(60 * 1000 * 2). Is there any way by which we can write it once instead of writing in every step file?
thanks a lot, really helpful. ✖ Given Go to google page # src/test/steps/first.ts:4 TypeError: Cannot read properties of undefined (reading 'goto') at World. for this error what should I do?
If you use an arrow function in Hooks, the reason you get an error is because the arrow functions have their own lexical context and do not correctly determine the this context. Hooks use context significantly and this context must be set as expected by the hook function.
Instead, you should use regular function definition in hooks instead of arrow function. Normal functions automatically get the context and this context is set correctly.
Yes, thanks for the explanation.
Very good demo, man. Impressive stuff
Thanks 😊
Bro.. your videos are absolutely great.. but it would be great if you share the code base as well ..
1-playlist = 1 repo and per video per branch..
Thanks, the source code is in the description.
GitHub link
github.com/ortoniKC/Playwright_Cucumber_TS
can you suggest changes if i have list of devices defined in playwright config ts file and want to use that instead of defining specific browsers in the hooks
Playwright config and cucumber config are different, we cannot use them from there.
Very helpful thanks
Welcome 😄
Hello my friend, in the minute 7:04 you do an import from qick fix.. There is an extensión for that? Thanks
That's the vscode feature, you can click on the bulb icon to get the quick fix.
I added code as you have instructed Kuoshik but when I run the test I get this error in hooks file - "SyntaxError: Cannot use import statement outside a module". The only difference is in my project application, they already have typescript and ts-loader installed. I am not sure if that would make the difference.
You have to use this
"resolveJsonModule": true
In your tsconfig file.
why is it like same things run in your device does not run in my device. like cucumber extension automatically take from feature to step function but it does not work in my system. Also this video's adding to cart using two users does not work.
😅, I'm not hiding anything.
You might have missed a few things.
Please watch the whole playlist once, you'll definitely get all the answers.
Hi Koushik,, thanks for the videos. It's really helpful. I am seeing issue in navigating from features file to respective definitions when I using ctrl plus click. It doesn't show underscore in gwt on pressing ctrl button. What could be issue and how can I fix that?
Hi. In the part 1 video i have explained the configuration, did u follow that?
@@letcode yes, but still I am facing issue, rest everything working fine
Share your screenshots here discord.gg/rK9Mr3YA
I'll check.
Great tutorial. I am facing the below issue:
1. I copied the step definitions generated and pasted them. When I ran the command “npm run test” I am getting steps undefined?
Could you please help me with the above issue?
Is the required and path values are set properly?
@@letcode yes
@@letcode yes
It must be path issue only, rewatch the first video about configuration.
Instead of creating a pageFixture to store the shared objects, could we use the "world" provided by cucumberJS? Is there a best practice on this?
Yes we can, but I thought this implementation will be easier.
@LetCode with Koushik When I am running with npm run test getting below issue. its not picking the scenarios. Also tried with your repo . its same issue
1 scenario (1 skipped)
2 steps (2 skipped)
0m00.003s (executing steps: 0m00.000s)
Is dryrun false?
@@letcode I changed it to false and it worked . Thanks
hI koushik
can you please create video on api testing with cucumber and playwright as well as tracing functionality video too.
Ok
Hi Bro, your video is really helpful and it is very clear for learning . Can you pls post video how to connect this project to saucelab integration
I will try bro.
excellent
Thank you! Cheers!
Hi, I am reciving this error :
error TS2305: Module '"../../hooks/PageFixture"' has no exported member 'PageFixture'.
2 import { PageFixture } from "../../hooks/PageFixture";
Have you added an export default class ?
Thanks it is very helpful. Can you please help how we can use soft assertion in playwright with cucumber Typescript. The existing playwright method .soft() is not working over cucumber framework.
Soft assertion is specific to the playwright test runner only.
Cucumber runner will not understand that.
@@letcode is there any alternate way to perform soft assertion in cucumber bdd typescript
I'm not sure for now, I'll check.
Hi Kaushik,
Previously I was facing "TypeError: Cannot read properties of undefined" for .locator then I have done all your mentioned changes in hooks and pageFixture files, it is working for .locator(pre-define) methods now, but when I am trying to call POM method in step def file, it is showing me that similar error "TypeError: Cannot read properties of undefined"(this is working fine for single feature file, but when I have created multiple feature files then it started showing mi this undefined error while accessing POM method)
Hi, it should work for one or multiple, the problem here i guess is u r not passing the page object properly to all the files.
@@letcode Yes, got it, Thank You.
I have another question regarding maintenance, If there will be any major UI changes in future(and no unique locators currently) then will it be feasible to use your mentioned folder structure or should we use any other approach for script maintenance? Could you please suggest??
@@jagrutibachhav-m4o i always prefer to keep my locators and method with in the same class.
It will be easier to find the locator changes and fix it.
I am trying this is in Mac OS, my feature file doesnt show link to step definition, have tried the keyboard shortcut, but no use
Did u do the steps mentioned in first video of the playlist?
Yes, I did follow step, my test works, but the link is not shown
May be the plugin issue.
@@letcode updated plugin, had installed some other, working now. Thank you for quick response and helpful video
@@P-nf7vl great 😃
9:20 but how to do it without ts-ignore?
It is used to ignore the compile time issue.
I don't think we have alternate for that.
Hi Koushik - how to run feature files(sequential order) not scenario
By default it runs by the alphabetic order, not sure how to sequence it, I'll check and let u know.
@@letcode thanks brother, waiting for you
VError: a BeforeAll hook errored, process exiting: src\hooks\hooks.js:13: Cannot set properties of undefined (setting 'page')
Check the code example, link in the video description.
I guess, u have used issue with local and global scope page variable.
Hi Bro,
I am getting error locator. textcontent: Timeout 30000ms exceed. Waiting for locator, how to fix this issue
Is the locator correct?
Try with different XPath or any other locator.
@@letcode Error: function uses multiple asynchronous interfaces: callback and promise
to use the callback interface: do not return a promise
to use the promise interface: remove the last argument to the function i am getting error.
to use the text content u have to use the await locator.textContent();
How to create page object model for this framework ??
ruclips.net/video/kl6jR6vHqZg/видео.htmlsi=qtH6Sx-foQY15z7e
I'm getting an "Error: Cannot find module ~pageFixturePath~ imported from ~stepsPath~"
Pls follow the steps from the 1st video.
@@letcodeI m getting the same error after following the steps from 1st video
Can you please share the solution
Nice video! In every step defination file you are writing setDefaultTimeout(60 * 1000 * 2). Is there any way by which we can write it once instead of writing in every step file?
Yes we can from the hooks I guess.
But why we need this?
How to debug code using playwright with cucumber.kindly share the inputs
Ok bro, I'll create a video.
What's the solution for doing pageFixture without @ts-ignore
Adding declaration file should fix that
@@letcode What's a declaration file?
It's only a typescript feature, I'll add a video about it
Need one help, how we can set browser zoom at 67% in playwright?
Not sure, probably you can try setting using javascript window query.
Hi, why every-time new window open for one scenario and another(opening & closing behaviour) ?
Because in webdriverIO end2end open then browser closed after all tests passed, sorry i am new to playwright thats why am asking.
We can change that, it should be configured within the hooks
Thank you for sharing these videos. Could you please, add api testing to this cucumber with typescript videos?
Thank you.
Yeah, it's in progress. I'll start in a few weeks.
thanks a lot, really helpful.
✖ Given Go to google page # src/test/steps/first.ts:4
TypeError: Cannot read properties of undefined (reading 'goto')
at World.
for this error what should I do?
Is page is defined properly in hooks ?