Skip to content

Commit 014f645

Browse files
authored
Extract button background color in Playwright script q
Added extraction of button background color in Playwright test.
1 parent 9cf8a9e commit 014f645

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

pages/playwright/index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ <h2>Usefull snippets</h2>
4848
// extra step for codegen
4949
await expect(page.locator("body")).toHaveCount(1);
5050
./node_modules/.bin/playwright codegen http://0.0.0.0:5678/vite-project/dist/
51+
52+
// extract css of the element
53+
const button = await page.getByRole("button", { name: "OK" });
54+
const backgroundColor = await button.evaluate((el) => {
55+
return window.getComputedStyle(el).getPropertyValue("background-color");
56+
});
5157

5258
</script>
5359

0 commit comments

Comments
 (0)