I am new to playwright and am having trouble getting things. I am following the tutorials and trying to get a baseURL configured. I used the config example in the docs, and placed this into my playwright.config.ts (with other settings)
const config: PlaywrightTestConfig = {
use: {
baseURL: 'http://localhost:5173/tatsu',
},
}
but when my test runs, it says I'm navigating to an invalid URL which tells me it's not picking up the baseURL.
Error: page.goto: Protocol error (Page.navigate): Cannot navigate to invalid URL
=========================== logs ===========================
navigating to "/", waiting until "load"
============================================================
at ..\..\playwright\fixtures.ts:29
27 | const page = await browser.newPage({ storageState: undefined })
28 |
> 29 | await page.goto('/')
I am also using a fixture mostly copied from the authentication example here https://playwright.dev/docs/auth
This thread is trying to answer question "Why is the baseURL not working in Playwright despite following the tutorials and using the config example from the documentation?"
It seems like the baseURL is not being applied in the context of the custom fixture. This could happen if the custom fixture is creating a new browser context or page without inheriting the configuration.
In Playwright, the configuration specified in the playwright.config.ts file applies to the default fixtures provided by Playwright, like page. If you define a custom fixture that creates a new browser context or page, you may need to manually apply the baseURL.
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].