...
×

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

Author :

Pavankumar Nagaraj is an automation testing expert with over 12 years of experience, specializing in tools like Selenium, Protractor, Puppeteer, and Playwright, and skilled in Java, Python, and JavaScript

Pavankumar Nagaraj
Pavankumar Nagaraj

Pavankumar Nagaraj is an automation testing expert with over 12 years of experience, specializing in tools like Selenium, Protractor, Puppeteer, and Playwright, and skilled in Java, Python, and JavaScript

Seraphinite AcceleratorOptimized by Seraphinite Accelerator
Turns on site high speed to be attractive for people and search engines.