playwright
playwright copied to clipboard
[Feature] Add assertion in codegen: recording window should have a button to add assertion to code
Hi,
it would be good to have an assertion type code generation, not just action type. For example to check a text, I can not locator.has_text so I should use some other locator and add it to expect.has_text.
firstly I wanted to write that recorder should have this function, but I found this issue #13900 (separate selector generator) and I think this feature would be much better in a separate selector generator
BR, George
It's worth noting that the cypress team has abandoned their code editor
I did not use cypress, maybe there was some issue with that editor, and people did not use that. I do not know. But this editor is quite good, I think It worth to use and worth to develop further ;) I know about other not used editors ...
@unlikelyzero Nope cypress studio is back. https://www.cypress.io/blog/2022/08/30/how-to-use-studio-in-cypress-10-7/ It can modify existing tests and do assertions using right click.
Assertions to codegen would be a great addition. Here is an example use case:
- The subject matter expert of the application (who isn't familiar with coding) knows the critical workflows, can record the steps for a new test candidate
- They usually know which details are most important, eg. a VAT-code value that should be asserted. But they can't do it in codegen.
- If codegen would have assertion functionalities, they could generate the assertions as well.
This feature exist in Selenium IDE and makes life much easier )
+1
It's worth noting that the cypress team has abandoned their code editor
Cypress has a Studio that supports assertion (right click on element shows assertion popup)
+1
This would be very useful! +1
+1
+1
Would also like to be able to generate the screenshot command (page or element) from the code-gen UI.
+1 Also being able to set a priority order to selectors in the codegen or exclude elements like id when these are always dynamic.
+1
I like the way it was implemented for https://testproject.io. Without assertions, generated code is like a record and play macro and not a test.
Btw, thank you for all the great work so far! Loving Playwright!
+1
+1
+1
How I see it:
- while recording there is a shortcut to record
expect
on that element, for exampleCtrl
+Left mouse
or what ever suits Dev team and it's not in collision with browsers shortcuts and button on Codegen editor - after
expect
is called you can elevateexpect
assertion methods for user to choose one with most frequently used on top liketoBeVisible
,toHaveText
,toBe
..
Sounds good :)
Is it possible to expand codegen by creating plugins etc? I would want to generate the PageObjectModal type of code using the playwright.
+1, about Cypress: Update as of August 30, 2022: Cypress Studio has been reimplemented in Cypress 10 as of version 10.7.0! I find it very useful and make assertions pretty easy :)
+1
+1
+1
I can build this feature, but I need to understand. How it will be used in the workflow? If you want me to build this, set up a 15 min call https://calendly.com/rabansal/15min I can take it forward from there.
very important feature!
Very needed feature!
I use this for now: https://marketplace.visualstudio.com/items?itemName=csbun.playwright-extend https://github.com/csbun/playwright-vscode
Works great, it's based on playwright extension and add in vscode a new submenu in "Testing" with Assert, Wait.
I have to install playwright official extension, then this one, then uninstall the official one, reload and install the official one again to have the menu appear.
Released in v1.40.0.