Running Playwright tests in openQA » History » Revision 1
Revision 1/2
| Next »
rainerkoenig, 2023-06-29 09:37
First draft
Running Playwright tests in openQA¶
Note: At the time of writing this we're still experementing with an Agama Live-CD, so things might change over time.
Building blocks¶
e2e-agama-playwright repo on GitHub¶
The e2e-agama-playwright repo was created by Joaquin and is supposed to be the repository that provides the Playwright tests.
yupdate¶
This is a script provided with the Agama Live-CD. The main purpose (at least for the Yam squad) is to provide a method of updating the playwright code in the Live-CD which is located under /usr/share/agama-playwright
. For this use case we use yupdate patch <github_repo> <branch>
which uses the branch on GitHub to update the Playwright and agama configuration.
Integration of yupdate into openQA¶
PR 17228 implements test modules to call yupdate
from inside openQA.
The test module is stored under yam/agama/patch_agama.pm
and uses a setting YUPDATE_GIT
which is describred as follow:
YUPDATE_GIT | string | | Github link used by yast help script yupdate, format is repo#branch such as yast/agama#main.
Test module agama_installation¶
There is a test module yam/agama/agama-installation
that has the purpose to run the installation. For that it uses the following code:
assert_script_run('RUN_INSTALLATION=1 playwright test --trace on --project chromium --config /usr/share/agama-playwright take_screenshots', timeout => 600);
The take_screenshots
test for Playwright has some specialties that we need to know:
// check for multiple texts in parallel, avoid waiting for timeouts
let action = await Promise.any([
page.getByText("Product selection").waitFor().then(() => actions.setProduct),
page.getByText("None authentication method").waitFor().then(() => actions.setPassword),
page.getByText("Root authentication set").waitFor().then(() => actions.done),
]);
// optional product selection
if (action === actions.setProduct) {
await test.step("Select the product", async () => {
// select openSUSE Tumbleweed
await page.getByText("openSUSE Tumbleweed").click();
await page.screenshot({ path: "screenshots/product-selection.png" });
await page.getByRole("button", { name: "Select" }).click();
});
This means the test is able to determine if we're still on the product selection page and then select Tumbleweed.
if (process.env.RUN_INSTALLATION === "1") {
await test.step("Run installation", async () => {
// start the installation
await page.getByRole("button", { name: "Install", exact: true }).click();
await expect(page.getByText("Confirm Installation")).toBeVisible();
await page.getByRole("button", { name: "Continue" }).click();
Here we check if we run the test with RUN_INSTALLATION=1
(as our openQA test module agama_installation
does, so then we launch the installation by making Playwright click on the install button.
Keep that in mind if your adapted installation test module will call another Playwright test!
Experiments made so far¶
Updated by rainerkoenig over 1 year ago · 1 revisions