Playwright with TS - Create Custom Fixtures

  Рет қаралды 2,704

QA Automation Alchemist

QA Automation Alchemist

Жыл бұрын

Playwright with TS - Create Custom Fixtures

Пікірлер: 16
@ripperx444
@ripperx444 4 ай бұрын
Finally a good video that explains it all!! In your test there is a page fixture and your own fixture that's passed in. What happens if you have a persistent context and you want all your tests to use the context.page[0] from a fixture that changes the default context behavior. Can you have one fixture that is composed Extend.... Context: Use(context) Page: Use (context.page) Theh in text pass this page ?
@sakshirana7881
@sakshirana7881 7 ай бұрын
Followed the complete Playlist, U have done a great job sir, Thanks a lot!
@naveen190685
@naveen190685 7 ай бұрын
Short and crisp... Thank you
@mr.hgorgan1812
@mr.hgorgan1812 5 ай бұрын
on point, thank you!
@mahensphotography
@mahensphotography Жыл бұрын
Excellent explanation !! Thanks for sharing !
@lamvanbao4774
@lamvanbao4774 Жыл бұрын
very good looking forward to a new part
@polyconhousewares1187
@polyconhousewares1187 4 ай бұрын
Fixture is not working for me :( How can I solve it?? Error: Requiring @playwright/test second time,
@QaAutomationAlchemist
@QaAutomationAlchemist 4 ай бұрын
You are using two times playwright library in repo. Check node modules folder, it may be present twice
@QaAutomationAlchemist
@QaAutomationAlchemist 4 ай бұрын
If you encounter an error when requiring `@playwright/test` twice in your project, it's likely due to a conflict or duplication in the module loading process. Here's how you can troubleshoot and resolve this issue: 1. **Check Module Loading**: Ensure that you're requiring `@playwright/test` only once in your project. Look through your codebase, including all dependencies and test files, to identify any duplicate imports or requires. 2. **Review Package.json**: Check your `package.json` file to see if `@playwright/test` is listed as a dependency or devDependency more than once. If so, remove the duplicate entry and ensure that there's only one instance of `@playwright/test` listed. 3. **Check Node Modules**: Inspect your `node_modules` directory to see if there are multiple instances of the `@playwright/test` module installed. If so, it may indicate that different packages within your project have conflicting dependencies or are using different versions of `@playwright/test`. 4. **Update Dependencies**: Ensure that all dependencies in your project, including `@playwright/test`, are up-to-date. Running `npm update` or `npm outdated` can help identify outdated packages that may be causing conflicts. 5. **Resolve Dependency Conflicts**: If there are conflicting dependencies or versions in your project, you may need to manually resolve them by updating package versions or installing compatible versions of dependencies. 6. **Clear Node Cache**: Sometimes, clearing the Node.js module cache can help resolve issues with duplicate module loading. You can do this by running `npm cache clean --force` or deleting the `node_modules` directory and reinstalling dependencies (`npm install`). 7. **Restart Environment**: After making any changes to your project files or dependencies, restart your development environment (e.g., IDE, terminal, test runner) to ensure that the changes take effect. By following these steps and carefully inspecting your project setup, you should be able to identify and resolve any issues related to requiring `@playwright/test` twice in your project. If you continue to encounter problems, consider seeking assistance from the Playwright community or checking for known issues in the Playwright GitHub repository or documentation.
@iburahim786
@iburahim786 9 ай бұрын
How to use the same page instance entire test? mine every test page is closing and opening. Kindly suggest how to handle single page instances like login and use this page instance for subsequent tests without closing the browser. If possible please make some videos and share.
@QaAutomationAlchemist
@QaAutomationAlchemist 9 ай бұрын
Thanks for your question. Tests should be atomic nature, means any test should be able to run alone. If you need e2e test, please use POM and try to use reusable methods ( with business level) like addToCart(item) in POM.
@iburahim786
@iburahim786 9 ай бұрын
@@QaAutomationAlchemist I tried reusable methods using page fixtures and that always closing browser on every test. I am not sure how that will helpful when its more than 300+ test cases. Running time might be increase because of this nature.
@QaAutomationAlchemist
@QaAutomationAlchemist 9 ай бұрын
@@iburahim786 In Playwright, if you want to prevent the browser from closing at the end of a test fixture (e.g., after running all the tests in a fixture), you can do this by configuring the fixture with the `preserveOutput` option. This option tells Playwright to keep the browser instance alive after the fixture finishes. Here's how you can use it: ```javascript const { test, expect, fixtures } = require('@playwright/test'); fixtures.fixture('').runWith({ preserveOutput: true }); test('Your Test Case', async ({ fixtureName, page }) => { // Your test code here await page.goto('example.com'); // Additional test steps }); ``` By setting `preserveOutput: true`, the browser will not be closed automatically when the test fixture completes. This is particularly useful if you want to share the same browser instance among multiple test cases within a fixture. Be cautious when using this approach, as it may lead to resource leaks if the browser instances are not properly closed at some point. You should manually close the browser instance when you're done with it, typically in an `afterEach` or `afterAll` hook, depending on your test structure: ```javascript const { test, expect, fixtures } = require('@playwright/test'); fixtures.fixture('').runWith({ preserveOutput: true }); test('Your Test Case', async ({ fixtureName, page }) => { // Your test code here await page.goto('example.com'); // Additional test steps }); afterAll(async () => { // Close the browser instance to avoid resource leaks await browser.close(); }); ``` Make sure to handle browser cleanup properly when using `preserveOutput` to maintain a clean testing environment.
@QaAutomationAlchemist
@QaAutomationAlchemist 9 ай бұрын
@@iburahim786 playwright.dev/python/docs/auth This explains how to reuse sign in state to avoid multiple login steps
@mahensphotography
@mahensphotography 9 ай бұрын
@@QaAutomationAlchemist Can you make a small video on this.Explanation from you is really awesome! Looking forward !!
PLAYWRIGHT ACCESSIBILITY TESTING IN DETAIL
24:24
CommitQuality
Рет қаралды 3 М.
ВОДА В СОЛО
00:20
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 29 МЛН
Опасность фирменной зарядки Apple
00:57
SuperCrastan
Рет қаралды 8 МЛН
Playwright Tutorial | Pass Test data as Fixtures
15:59
WishInfinite
Рет қаралды 1 М.
Playwright - Turn Page Object Model Pages into fixtures
7:08
CommitQuality
Рет қаралды 10 М.
Don't put your types in .d.ts files
3:54
Matt Pocock
Рет қаралды 132 М.
PyTest • REST API Integration Testing with Python
37:24
pixegami
Рет қаралды 78 М.
TypeScript Origins: The Documentary
1:21:36
OfferZen Origins
Рет қаралды 279 М.
Understanding Fixtures in Playwright: A Comprehensive Guide for Testers
11:19
ВОДА В СОЛО
00:20
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 29 МЛН