![Cover image for Behavior Driven Development (BDD) using Playwright](https://media.dev.to/cdn-cgi/image/width=1000,height=420,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fswetkwdnkxp39lkevjea.png)
Playwright is an open-source NodeJS framework for browser automation. It is developed by Microsoft and the development team has members that were i...
For further actions, you may consider blocking this person and/or reporting abuse
Thanks for the good article!
Hi, I'm not sure where you're getting the
page
object from in yourtodoContext.js
file. This doesn't run for me while having the same config, and I getReferenceError: page is not defined
, any ideas why?Hi sorry for the late reply but page is created in
cucumber.conf.js
file and is set global so that it can be used across all the other filesit's still not working
After rename cucumber.config.js to cucumber.conf.js, everything ok.
When execute it i am getting,
but still i am getting undefined for steps even though those are defined
and the thread issue is still not working for me
FYR
About the import issue, there's a few possible solutions.
One could be to add "type": "module" to your package.json. Another cause could depend on if you're using typescript commonJS or esNext. take a look at those two possible fixes.
Thanks for the article!
Inspired by it I've created playwright-bdd package that allows to run Cucumber tests with Playwright. The only difference is that it uses Playwright as a test runner and utilizes Cucumber as a library.
Hello, I see your project - playwright-bdd-example. This is what I'm trying to implement. Could you please answer to my questions? Where you are launching the browser? Just giving the device in playwright-config.ts is enough? And the same project can be done in javascript as well?
Hello! Yes, just giving the device in playwright config is enough, b/c tests are actually normal Playwright tests. The same can be done in JavaScript as well
Hi, Thank you very much for the sharing. It is great, but when start to run, I always got this error:
Parse error in "tests\acceptance\features\todo.feature" (1:1): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got '// todo.feature'
I am still learning. Could you please give me some help?
Thank
Shane
I think you should remove the following
// todo.feature
from your featurefile because of your lintersettings?
Oh, right. Did forget that. :)
Thanks a lot.
github.com/vitalets/playwright-bdd there is now a dedicated PLaywright-BDD runner which allows you to write Cucumber tests using the playwright runner directly.
It really streamlines the code, means you can directly use the Playwright.config.ts file to store all your browser config, and automatically creates a new context for every test. You can also use Playwright Fixtures to streamline your test and your framework. I have been porting our Cucumber project across and don't think I will use the cucumber runner ever again.
Hi Brother. Do you have the same sample repo project for PlayWright with BDD frame work java. Do you have a mail id to reach out?
Thanks for this. I am just wondering how we can shard these tests and run in multiple machines at the same time?