Thanks for sharing valuable info.QQ Under formPage.ts ;if line 4 is replaced with public static fname = '#firstname'; then line 16 await this.page.locator(Form.firstname).type(fname); My current real-time (POM)project looks like the above. Is this also considered a proper coding standard? Your input is highly appreciated.
Thanks for asking . You can use it. However, Use static variables when you want to share data or configuration across all instances of a class. Use instance variables (accessed via this) when you need to store and access data that is specific to each instance of an object. Better use "this", as it will be individual instance, so that you can change ( in specific test and will not impact other test ) or use in parallel testing.
awesome content, nice and easy with the screenshot and video options in the config file. One question: in the case of a major project with hundreds of tests, will those features (screenshot and video capture) hinder the test run speed?
Thanks for sharing valuable info.QQ
Under formPage.ts ;if line 4 is replaced with
public static fname = '#firstname';
then line 16
await this.page.locator(Form.firstname).type(fname);
My current real-time (POM)project looks like the above. Is this also considered a proper coding standard? Your input is highly appreciated.
Thanks for asking . You can use it.
However,
Use static variables when you want to share data or configuration across all instances of a class.
Use instance variables (accessed via this) when you need to store and access data that is specific to each instance of an object.
Better use "this", as it will be individual instance, so that you can change ( in specific test and will not impact other test ) or use in parallel testing.
@@QaAutomationAlchemist Thank you for your explanation.👍
awesome content, nice and easy with the screenshot and video options in the config file. One question: in the case of a major project with hundreds of tests, will those features (screenshot and video capture) hinder the test run speed?
You can set video and screenshots on only test failures
Go to Playwright. config. ts file and under use add the flag screenshot: 'only-on-failure'.