Rayrun

How do I change the baseURL in Playwright for a specific test?

Answer

Sure, you can override the baseURL in @playwright/test. This comes in handy when you're using methods like page.goto(), page.route(), page.waitForURL(), page.waitForRequest(), or page.waitForResponse().

Here's how you can do it:

// Assuming your base URL is https://ray.run
page.goto('/blog'); // This will navigate to https://ray.run/blog

This way, you can navigate to any location without changing your entire configuration file.

Remember, this only affects the specific test you're running. It doesn't change the global configuration for other tests.

If you're running multiple web servers with different configurations, each server will have its own baseURL value.

So, yes, you can have greater flexibility and control over navigating pages during testing by overriding the baseURL value in Playwright.

References

Thank you!
Was this helpful?
Still have questions?

If you still have questions, please ask a question and I will try to answer it.

Related Questions

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 [email protected].