Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get current page url with Playwright Automation tool? [closed]

is it possible to get the current url from the page in PLaywright? I can't seem to find any information in the docs.

Something like this:

let url = await page.url
like image 622
gabogabans Avatar asked Oct 11 '20 20:10

gabogabans


People also ask

How do you get the current page URL?

Answer: Use the window. location. href Property location. href property to get the entire URL of the current page which includes host name, query string, fragment identifier, etc.

How do I get the current URL in Python?

You can get the current url by doing path_info = request. META. get('PATH_INFO') http_host = request. META.

What is Page in playwright?

Page provides methods to interact with a single tab in a Browser, or an extension background page in Chromium. One Browser instance might have multiple Page instances.


1 Answers

const {browser}=this.helpers.Playwright;
await browser.pages(); //list pages in the browser

//get current page
const {page}=this.helpers.Playwright;
const url=await page.url();//get the url of the current page
like image 193
Himanshu Bhardwaj Avatar answered Sep 24 '22 12:09

Himanshu Bhardwaj