How to globally define baseURL in Playwright?

Viewed 29

In my test automation, I have several domains that I want to test with a similar SUT. So I would like to use baseURL to easily switch between systems. if I understand correctly there are 2 ways to define the baseURL. Local and global. As long as I define locally everything works as expected:

test.use({
    baseURL: "https://www.url1.de"
  })

async gotoPDP() {
  const url = '/path1'
  await this.page.goto(url)
  await expect(this.page).toHaveURL(url)
}

url expands to https://www.url1.de/path1 as expected.

If I set in the file playwright.config.ts the global baseURL

use: {
  headless: true,
  actionTimeout: 0,
  baseURL: 'www.url1.de'
},

and skip the local definition it is not applied. url stays /path1. Why?

0 Answers
Related