So I followed this guide to starting Playwright with Cucumber-JS and instead pointed to my company's website; however, the page never seems to load, even if I set the timeout to something ridiculous (like 1,000,000 ms)
I don't know why my page never seems to load when using the await, but removing the await it can't find the next part. Here's my code to show you what I mean:
Step Definitions file (steps.js)
const { Before, Given, When, Then } = require("@cucumber/cucumber");
const playwright = require("@playwright/test");
var page;
Before( async function() {
var browser = await playwright.chromium.launch({
headless: false,
});
var context = await browser.newContext();
page = await context.newPage();
});
Given("a {string} is not logged in", { timeout: 1000 * 1000 }, async function (stringParam) {
await page.goto('[MY-WEBSITE]');
await page.getByText("[SOME-TEXT-TO-VERIFY-I-AM-AT-MY-WEBSITE]");
});
When("a {string} signs in at the start", { timeout: 1000 * 1000 }, async function (stringParam) {
await page.getByText('Enter your email');
page.getByText('Enter your email').fill("[FILL-IN-FORM-HERE]");
await page.getByText('Password (8+ characters)');
page.getByText('Password (8+ characters)').fill("[FILL-IN-FORM-HERE]");
await page.getByText('Join now for free');
page.getByText('Join now for free').click();
});
Feature file (login.feature)
Feature: MY-FEATURE
Scenario Outline: Sign in to the webpage from the signed-out home screen
Given a "<UserType>" is not logged in
When a "<UserType>" signs in at the start
Then the user is signed in
Examples:
| UserType |
| User1 |
Command I use to run:
./node_modules/.bin/cucumber-js --exit
Console output:
.F-
Failures:
1) Scenario: Sign in to the website from the signed-out home screen # features/login.feature:15
✔ Before # features/support/steps.js:5
✖ Given a "User1" is not logged in # features/support/steps.js:13
page.goto: Timeout 30000ms exceeded.
=========================== logs ===========================
navigating to "[MY-WEBSITE]", waiting until "load"
============================================================
at World.<anonymous> (/Users/sam.levene/Git/playwright-poc/features/support/steps.js:14:16)
- When a "User1" signs in at the start # features/support/steps.js:18
My page is fairly simple, with a pretend login form that has these fields upon loading of the page; so it shouldn't take an age to load (especially because the backend of the page is driven by PHP)
Can anyone help me explain why the await never seems to work and the page never loads inside the timeout?