Vladeezy
Vladeezy

Reputation: 187

how to add to baseURL some arguments?

I'm having a link like baseURL: 'https://www.aaa.com/CPC/?agentcode=123&hotelcode=123', and if i'm using the value from baseURL, it cuts it to https://www.aaa.com but I need to navigate to page from baseURL, using the whole URL which I expect, as I understand, baseURL is doing its job and works properly, but anyway I need somehow to add everything what goes after .com part also. How can it be done ?

Upvotes: 0

Views: 1945

Answers (1)

Amol Chavan
Amol Chavan

Reputation: 3980

You can just use .goto method, from documentation -

url URL to navigate page to. The url should include scheme, e.g. https://. When a baseURL via the context options was provided and the passed URL is a path, it gets merged via the new URL() constructor.#

Example - You can configure the base URL as below using the global config file playwright.config.ts

import { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
  use: {
    baseURL: 'https://www.aaa.com',
    browserName: 'firefox',
    headless: true,
  },
};
export default config;

then you can use it a tests like below for navigation -

    test.describe('Intent of the Test', () => {
        test('should allow me to add todo items', async ({ page }) => {
           await page.goto('/CPC/?agentcode=123&hotelcode=123');   
        })
   });

Upvotes: 2

Related Questions