Rayrun
← Back to videos

Playwright Base URL | Playwright Tutorial - Part 39

New baseURL fixture to support relative paths in tests.

In this video, the host explores the base URL feature of the Playwright test runner. The video begins by introducing the concept of a base URL and explaining that it can be configured globally or locally.

To configure the base URL globally, the host goes to the playwright.config.ts file and adds the base URL to the "use" object. The specific base URL used in the example is "https://letgo.in". The host also mentions that the page URL after the base URL needs to be appended with a slash.

The video then shows how tests can be written using the base URL. Previously, without the base URL, the tests used full URLs like "https://letgo.in/signin" or "https://letgo.in/test". However, with the base URL configured, the tests only need to use the specific page URL like "/signin" or "/test".

The host demonstrates running the tests and shows that they pass. Screenshots of the test results are also shown.

Next, the host creates a copy of the test file and wants to run the copied test file with a different base URL of "https://play.letgo.in". The host explains that to override the global configuration, a local configuration can be used. In this case, the local configuration is added to the specific test file using the "test.use" object and specifying the base URL.

The video concludes by running the tests again and showing that all tests pass. A new screenshot report is generated to illustrate the results.

The video ends with the host summarizing the concepts covered and expressing that the base URL feature is useful and easy to understand.

Related Videos

#16 - ARIA and how Playwright is making use of it to identify UI controls?
#16 - ARIA and how Playwright is making use of it to identify UI controls?
Create feature, steps & config | Playwright & Cucumber - Typescript | Part 1
Create feature, steps & config | Playwright & Cucumber - Typescript | Part 1
Playwright - Set timeout, parallelisation and retries directly in your test files
Playwright - Set timeout, parallelisation and retries directly in your test files
Working with multiple elements in Playwright Test (NodeJS)
Working with multiple elements in Playwright Test (NodeJS)
TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

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 luc@ray.run.