PlayWright Interview Questions And Answers - Freshers & experienced up to 2 years
Ans. Playwright is an open source tool developed by Microsoft for automation testing of web applications and mobile applications. It is also used for API automation.
Ans. The operating systems which are supported by playwright are:Windows,MacOS and Linux operating systems.
Ans. The browsers supported by playwright are Chromium,Webkit,Firefox,Chrome etc.
Ans. The programming languages supported by Playwright are Javascript,Typescript,Java,C#,Python.
Ans. Locators are used to detect the elements or components present in the web page. The various locators used in Playwright are ID,Name,ClassName,CSS selector, Xpath,Text Content,TagName,AltText,Attribute,Label,Role,Title,TestID
Ans. await page.goto(“url link”);
Ans. const currentUrl= await page.url();
Ans. const title = await page.title();
Playwright | Selenium |
Supports cross browser automation chromium,webkit | Does not support cross browser automation in chromium, webkit, |
Does not require webdriver installations since drivers are in built. | Requires webdriver installations since drivers are not inbuilt. |
Playwright supports programming languages like NodeJS, JavaScript. | Selenium does not support programming languages like NodeJS, JavaScript. |
Playwright supports running of test scripts through inbuilt test plugins as well as through third party tools like Mocha ,Jest ,Jasmine etc. | Selenium does not support running of test scripts through inbuilt test plugins but rather it only depends on third party tools likeTestNG,Junit, Mocha ,Jest ,Jasmine etc. for running test scripts. |
It does not require browser specific drivers for performing parallel testing and cross browser testing. | It requires browser specific drivers for performing parallel testing and cross browser testing. |
The architecture of Playwright is that it follows Web Socket protocol. | The architecture of Selenium is that it follows JSON wire/HTTP protocol. |
It supports API Automation and mobile application testing. | It does not support API Automation and mobile application testing.For mobile application testing a third party tool like Appium is required. |
It can be used for visual and screenshot comparison. | It cannot be used for visual and screenshot comparison.style=#000000 |
Ans. 1. Using Playwright, testers can perform cross browser testing in different browsers like chrome,firefox, chromium etc. which involves running test scripts in different browsers one after another.
- Playwright is helpful in automation testing of advanced web applications using React,NodeJs as well as in automation of more complex single page applications.
- Playwright helps immensely in performing System testing which is also the end to end testing, involving navigation from the home page of the application to the last page of that application as well as interaction with different components of each page.
- With the help of Playwright, testers can perform parallel testing using different browsers which involves running test scripts simultaneously in different browsers.
- Using Playwright testers can keep a record of the test cases or scripts executed.
- Playwright does not require the use of any wait command like explicit wait for running test scripts since it automatically performs wait actions.
- Testers can perform image based testing like screenshot comparison,visual comparison through playwright.
- Playwright can be used in performing automated regression testing by integrating with CI/CD pipeline to make sure that any code changes do not affect the existing functionality of the application.
- Using Playwright automation scripts can be run in different operating systems like windows, Linux and MacOS.
- Testers can also perform mobile testing effectively using Playwright
Also read : Java Interview Questions and Answers
Ans. 1. Playwright is not compatible with Safari Browser.
- Since it is relatively new to the market, sometimes effective test execution may not happen.
- Although Playwright supports mobile application testing,it still does not support automation testing of native mobile applications.
- Playwright is difficult to learn for those people who have zero knowledge of coding.
- Not suitable for performing unit testing.
- Playwright does not support cloud based testing.
- Whenever testers do not perform cross browser testing, use of playwright becomes unnecessary.
- For very small projects with limited budget usage of playwright is not justifiable.
Ans. Playwright supports API Testing,Parallel Testing,CrossBrowser Testing, System Testing, Component Testing, Functional Testing.
Ans. await page.locator(‘input[type=”text”]’).fill(‘Hello, world’);
await page.locator(‘input[type=”text”]’).type(‘Hello, world’);
Ans. await page.locator(‘selectorname’).clear();
Ans. await page.locator(‘selectorname’).innerText();
Ans. Using isVisible() method we can check if given element is displayed or not. Syntax: await page.locator(‘selectorname’).isVisible();
Ans. Using isChecked() method we can check if given element is selected or not. Syntax: await page.locator(‘selectorname’).isChecked();
Ans. Syntax to check whether button is enabled:
await page.locator(‘your-selector’).isEnabled();
Syntax to check whether button is disabled:
await page.locator(‘your-selector’).isDisabled();
Ans. The different assertions used in playwright are
- expect(value).toEqual(expected)
- expect(value).toBeTruthy()
- expect(value).toBeFalsy()
- expect(locator).toContainText(expected_text):
- expect(locator).toHaveClass(expected_class)
- expect(value).toBe(expected)
Ans. Using Assertion if the test fails the test execution stops.By using soft assert text execution continues even if the test fails and the test status will be marked as failed at the end of execution.
Ans. page.goto(‘https://example.com’);
await page.reload(); // Refresh your current page
await page.goBack(); // Takes one page backward based on browser’s history
await page.goForward(); // Takes one page forward based on browser’s history
Ans. await page.locator(‘your-selector’).contextMenu();
await page.locator(‘your-selector’).click({ button: ‘right’ });
Ans. await page.locator(‘your-selector’).dblclick();
Ans. The various reports supported by Playwright are
- Dot reporter
- Line reporter
- HTML reporter
- JSON reporter
- JUnit reporter
- Custom reporter
Also read:
Consult Us