Page level commands in Playwright Python
There are a few operations that you can perform on the page using Playwright. We will be discussing comments that are widely used.
goto():
Navigate to a new URL using goto
function
page.url
url
Get the URL of the current webpage
page.title()
title
Get the title of the webpage, you can notice on the table level
page.title()
content
Get the HTML content of the web page. This will be useful to see whether a particular string is present when you want to check whether a particular particular element is present.
page.content()
The complete code
from playwright.sync_api import sync_playwright
playwright = sync_playwright().start()
browser = playwright.chromium.launch(headless=False)
page = browser.new_page()
page.goto("https://google.com")
print(page.url)
print(page.title())
print(page.content())
Posts You Might Like
- Why playwright is better than selenium webdriver, is it?
- Handle dropdowns in Playwright Python
- Open the browser and Close in Playwright Python
- Handle checkbox in Playwright Python
- Element Operations in Playwright Python
- Handle IFrames in Playwright Python
- Page level commands in Playwright Python
- Element State with Playwright Python