Turn your manual testers into automation experts Request a DemoStart testRigor Free
Playwright Logo

Playwright Alternative

End-to-end testing is an integral part of determining if the application under test is ready for mass consumption. With this type of testing, you verify if different parts of the application are working together to produce the expected results. Among the many tools available in the market for end-to-end testing, Playwright is gaining popularity. Although, due to its limitations and the emergence of other technological trends, you might find an alternative, such as testRigor, to deliver a better value. Let’s take a look at both of these tools below.

What is Playwright?

Playwright is a node.js-based framework maintained by Microsoft, created specifically to meet the needs of end-to-end testing. It supports all modern rendering engines, including Chromium, WebKit, and Firefox, along with testing on Windows, Linux, and macOS, locally or on CI, headless or headed, with native mobile emulation of Google Chrome for Android and Mobile Safari.

Advantages of Playwright

Playwright is a good option for automating end-to-end tests, especially for developers. Some of its advantages are:
  • It supports cross-browser and cross-platform testing on Windows, Linux, and macOS, locally or on CI, headless or headed.
  • The Playwright API can be used in TypeScript, Java, .NET, JavaScript, and Python.
  • It supports mobile web testing with native mobile emulation of Google Chrome for Android and Mobile Safari.
  • Playwright has an auto-wait capability which waits for elements to be actionable before performing actions.
  • It can test scenarios that span multiple tabs, multiple origins and multiple users. You can also create scenarios with different contexts for different users and run them against your server, all in one test.
  • Playwright selectors pierce shadow DOM and allow entering frames seamlessly.
  • It provides the capability to record interactions with the browser and generate test scripts in any language.

Writing tests with Playwright

With Playwright, you can easily write actions in the form of steps and then assert the state against expectations.There is no need to wait for anything before performing an action. Playwright automatically waits for many of the actionability checks to pass prior to performing each action. Actions include navigations and interactions.

Playwright includes test assertions in the form of expect function. To make an assertion, you need to call expect(value) and choose a matcher that reflects the expectation. There are many generic matchers like toEqual, toContain, and toBeTruthy that can be used to assert any conditions.

Additionally, you can use test hooks to declare a group of tests and test.beforeEach and test.afterEach which are executed before and after each test respectively. Other hooks include the test.beforeAll and test.afterAll which are executed once per worker before/after all tests.

Here's an example of a test using Playwright for checking products on Amazon.

const { test, expect } = require('@playwright/test');
test('Amazon search for headphones on PC page', async ({ page }) => {

  await page.goto('https://www.amazon.com/');
  
  await page.click('.nav-logo-link');
  
  // Check that page contains "Amazon Devices" below "Get to Know Us"
  const getToKnowUsText = await page.$eval('a[href="/amazon-devices/b/?ie=UTF8&node=2102313011"]', (el) => el.textContent);
  expect(getToKnowUsText).toContain('Amazon Devices');
  
  await page.click('a[href="/amazon-devices/b/?ie=UTF8&node=2102313011"]');
  
  // Check that page contains "Echo & Alexa"
  const echoAlexaText = await page.$eval('a[href="/Echo-Devices/b/?ie=UTF8&node=9818047011"]', (el) => el.textContent);
  expect(echoAlexaText).toContain('Echo & Alexa');
  
  await page.click('a[href="/Echo-Devices/b/?ie=UTF8&node=9818047011"]');
  
  // Check that page contains "Alexa App" below "Alexa Resources"
  const alexaResourcesText = await page.$eval('.s-navigation-indent-1 a[href="/gp/help/customer/display.html/?nodeId=GJDWQ6WJ6VYJX9XN"]', (el) => el.textContent);
  expect(alexaResourcesText).toContain('Alexa Resources');
  const alexaAppText = await page.$eval('.s-navigation-indent-2 a[href="/gp/help/customer/display.html/?nodeId=GDKGDTXNTH7A5BQA"]', (el) => el.textContent);
  expect(alexaAppText).toContain('Alexa App');
  
  await page.click('.s-navigation-indent-2 a[href="/gp/help/customer/display.html/?nodeId=GDKGDTXNTH7A5BQA"]');
  
  // Check that page contains "Search Amazon"
  const searchAmazonText = await page.$eval('label[for="GLUXSearchInput"]', (el) => el.textContent);
  expect(searchAmazonText).toContain('Search Amazon');
  
  await page.fill('#GLUXSearchInput', 'headphones');
  await page.press('#GLUXSearchInput', 'Enter');
  await page.waitForNavigation();
  await page.click('a[href*="headphones"]');
  await page.evaluate(() => window.scrollBy(0, window.innerHeight / 2));
  
  // Grab value from "Sony ZX Series Wired On-Ear Headphones, Black MDR-ZX110" and save it as "headphone1"
  const headphone1Text = await page.$eval('a[href*="MDR-ZX110"] span', (el) => el.textContent);
  const headphone1 = headphone1Text.trim();
  
  // Grab value from "Beats Solo3 Wireless On-Ear Headphones"
  const headphone2 = await page.innerText('text=Beats Solo3 Wireless On-Ear Headphones - Apple W1 Headphone Chip, Class 1 Bluetooth, 40 Hours of Listening Time, Built-in Microphone - Black (Latest Model)');
  await page.evaluate(() => window.scrollBy(0, -window.innerHeight/2));
  
  await page.fill('input[type="search"]', 'pc');
  await Promise.all([
    page.waitForNavigation(),
    page.click('text=pc')
  ]);
  
  // Check that page does not contain "headphone1"
  const hasHeadphone1 = await page.isVisible(`text=${headphone1}`);
  expect(hasHeadphone1).toBeFalsy();
  
  // Check that page does not contain "headphone2"
  const hasHeadphone2 = await page.isVisible(`text=${headphone2}`);
  expect(hasHeadphone2).toBeFalsy();
})

Limitations of Playwright

Playwright has several limitations despite its powerful capabilities. One of its primary limitations is its reliance on JavaScript, which means that developers without prior experience in JavaScript or Node.js might face a steep learning curve. Additionally, Playwright's support for mobile testing is limited, as it only provides emulated mobile devices rather than real devices, which may not accurately represent actual user experience.

Another limitation of Playwright is its lack of native support for visual testing or reporting, as it requires third-party integrations to conduct these tasks effectively. This could potentially increase the complexity of the testing process and necessitate additional maintenance efforts.

Furthermore, Playwright's documentation, while extensive, may not always be up-to-date or cover all use cases, which might make it difficult for developers to find solutions for specific issues. Finally, as Playwright is a relatively new tool, it may not have the same level of community support or resources as more established testing frameworks.

Why is testRigor a more viable option?

Quality assurance is paramount for ensuring competency in the market these days. With all the advancements in the field of testing AI/ML-based engines and codeless tools, it is becoming easier to make quality assurance holistic by involving both technical and non-technical stakeholders in the process. Moreover, these advancements also aid cost-cutting and higher productivity in organizations. One such powerful tool that leverages the benefits of these technologies is testRigor. Let's take a look at its capabilities and see how easy it is to use.

You have the following advantages with testRigor:
  • It is a codeless tool, meaning tests are written using plain English commands. This opens the ability for the entire testing team to author tests (including manual testers) and significantly increases the speed of creating tests.
  • A record-and-playback tool can further speed up test creation. Since the recorded tests will be in the same plain English format, it becomes viable for anyone to edit and maintain when desired.
  • There is no hassle mentioning XPaths or any technical parameters for locating elements on the screen. All you need to do is mention relative positions. You can click on a button below the title by simply writing click "button" below "Title"
  • The tool allows you to perform cross-browser and cross-platform tests; parallel execution feature allows to get the test results in minutes.
  • Being a cloud-based tool, the initial setup is extremely straightforward and only takes a few minutes.
  • Can be easily integrated with most CI/CD tools, test management tools, and issue-tracking tools.
  • Offers good reporting capabilities and captures screenshots at every step.
  • Supports web, native and hybrid mobile applications, native desktop, and API testing.

Writing tests with testRigor

Writing tests with testRigor is rather straightforward. The documentation explains all commands in detail, and you can even define your own preferred commands if desired.

Here is a sample test case for checking items on Amazon. It is the testRigor version of the code we saw above for the same scenario in Playwright. As you can see, testRigor provides true end-to-end testing, since scenarios represent the end user's perspective as close as it is technically possible.

click "amazon"
check that page contains "Amazon Devices" below "Get to Know Us"
click "Amazon Devices"
check that page contains "Echo & Alexa"
click  "Echo & Alexa"
check that page contains "Alexa App" below "Alexa Resources"
click  "Alexa App"
check that page contains "Search Amazon"
enter "headphones" in "Search Amazon"
click  "headphones"
scroll down by 1/2 of the screen
grab value from "Sony ZX Series Wired On-Ear Headphones, Black MDR-ZX110" and save it as "headphone_1"
grab value from "Beats Solo3 Wireless On-Ear Headphones - Apple W1 Headphone Chip, Class 1 Bluetooth, 40 Hours of Listening Time, Built-in Microphone - Black (Latest Model)" and save it as "headphone_2"
scroll up
enter "pc" into "headphones"
click on "pc"
check that page does not contain "headphone_1"
check that page does not contain "headphone_2"
Request a Demo
Ready to move your software testing into the next stage of scale and efficiency? After submitting this form, our team will reach out to you to schedule a demo where they can also answer your technical questions.

Loading…

The connection to the server timed out!

Thank you for your request. Please select date and time for a demo.