×
Page Level Commands Playwright Python

Page level commands in Playwright Python

Written by


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())

Author :

Senior Software Engineer in Test, with more than a decade of experience in automation tools like Selenium, Playwright, Protractor, and Puppeteer with Python, Java, and JS respectively.