Rayrun
โ† Back to Discord Forum

Can I run playwright tests on active browser window?

Hi - I am trying to make my website a11y compliant. I am using dynamically loaded components (reusable UI components that behave differently in different workflows). Can I run playwright tests on my active window to ensure that I am a11y compliant? My tech stack - VueJS frontend + Java springboot API + MySQL.

This thread is trying to answer question "Can I run playwright tests on my active window to ensure that I am a11y compliant?"

29 replies

by active window you mean currently launched browser?

@skorp32 sure. I was actually hoping to run the tests on an already launched browser where I am going to different screens and playwirght almost runs like in watch mode and checks my DOM for a11y compliance

kind of like in-browser testing

Kind of possible but not super simple I would say, you will need to launch Chrome with remote debugging port and then in Playwright connect to browser via an endpoint https://playwright.dev/docs/api/class-browsertype#browser-type-connect-over-cdp.

@skorp32 thank you. this is awesome. but how do i open a socket/port in chrome? the way i understand browsers, each browser tab is a V8 isolate. so i would need to expose a port for the tab context or would i expose all the tabs in chrome?

Something like this I suppose https://gist.github.com/bobdobbalina/64450fb391dab3863e047295cb155410. It will expose whole browser, afterwards you should be able to manipulate tabs with Playwright api like usually.

tphillips8117
@ven0007: Why not just get Playwright to do this in its own browser(s)?

Why not just get Playwright to do this in its own browser(s)?

@tphillips8117: I am new to DOM testing. so, to re-preface my question - I am testing for a11y compliance on about 600 views (based on workflow) - to allow Playwright in its own browser wouldn't you need to provide 600 routes (```page.goto('https://playwright.dev/');```)? from example.spec.js ```const { test, expect } = require('@playwright/test'); test('has title', async ({ page }) => { await page.goto('https://playwright.dev/'); // Expect a title "to contain" a substring. await expect(page).toHaveTitle(/Playwright/); }); test('get started link', async ({ page }) => { await page.goto('https://playwright.dev/'); // Click the get started link. await page.getByRole('link', { name: 'Get started' }).click(); // Expects page to have a heading with the name of Installation. await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible(); }); ``` @tphillips8117

I am new to DOM testing. so, to re-preface my question - I am testing for a11y compliance on about 600 views (based on workflow) - to allow Playwright in its own browser wouldn't you need to provide 600 routes (page.goto('https://playwright.dev/');)? from example.spec.js

test('has title', async ({ page }) => {
  await page.goto('https://playwright.dev/');

  // Expect a title "to contain" a substring.
  await expect(page).toHaveTitle(/Playwright/);
});

test('get started link', async ({ page }) => {
  await page.goto('https://playwright.dev/');

  // Click the get started link.
  await page.getByRole('link', { name: 'Get started' }).click();

  // Expects page to have a heading with the name of Installation.
  await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible();
});

@tphillips8117

tphillips8117

sure, but isn't that better than manually doing it? You must have a list of pages/routes you can pass in?

@tphillips8117: sure. the idea is to split the fixes across different teams (we have 10+ teams). What you are suggesting is a centralized fix. tthat would be me and my junior dev ๐Ÿ™‚

sure. the idea is to split the fixes across different teams (we have 10+ teams). What you are suggesting is a centralized fix. tthat would be me and my junior dev ๐Ÿ™‚

the idea is to get UAT (user acceptance) to raise bugs and assign by team

tphillips8117

so what would Playwright do?

tphillips8117
@ven0007: centralized, yes. But also automated and could be way less work in the long run

centralized, yes. But also automated and could be way less work in the long run

tphillips8117

Sorry, changed it to "could be way less work" I can't say it would be less work for sure.

tphillips8117

it just sounds like you're wanting to use playwright for only part of the test, but you could have it do the whole thing

@tphillips8117: "whole thing" meaning big picture? please elaborate

"whole thing" meaning big picture? please elaborate

what am i missing?

tphillips8117

I guess I might be misunderstanding your situation

playwright will only help identify the issues

it wont actually fix them for me

tphillips8117

You're wanting to browse to each page manually, then run a playwright script to find issues on that page?

as a watcher. yes

tphillips8117

I am wondering: Why not have playwright browse to each page itself, then run the test to find issues?

because our components behave differently based on the workflow they are in. we use "watchers" (in Vue they are watch OR watchEffect). they eventually render as static html but our component library is quasar and it does it own "stuff" on html elements

if quasar wasnt involved this would be a lot easier

tphillips8117

I am not very familiar with how Quasar affects pages/locators, I would think it shouldn't matter too much though.

tphillips8117
@skorp32: @ven0007 hopefully you get somewhere with this

@ven0007 hopefully you get somewhere with this

tphillips8117

Or work out a way to spare the user/UAT/dev having to browse to 600 pages ๐Ÿ˜„

@tphillips8117 LOL. Will keep you posted

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].