0% found this document useful (0 votes)
385 views6 pages

Automation Guide - Playwright With Java - Cheatsheet

Uploaded by

sankarraja.0018
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
385 views6 pages

Automation Guide - Playwright With Java - Cheatsheet

Uploaded by

sankarraja.0018
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

07/04/2023, 12:04 Box Notes

Playwright - Java Cheat Sheet - Browser Auto…

Author: Naveen Khunteta

Linkedin: [Link]

Playwright - Java Youtube Series: [Link]

Playwright is an open-source [Link] library for automating web browsers such as Chromium,
Firefox, and WebKit through a single API.

It allows developers to write browser automation scripts in a simple and intuitive way using the
programming language of their choice, including Java, JavaScript, Python, and others.

Playwright provides powerful features such as cross-browser testing, headless mode, request
interception, and more, making it a popular tool for testing and scraping web applications.

Playwright is maintained by Microsoft and is designed to be fast, reliable, and easy to use.

Method/Property Description

[Link]() Creates a new instance of Playwright.

[Link]() Launches a new browser instance.

[Link]() Creates a new browser context.

[Link]() Creates a new page in the current context.

[Link]() Navigates the current page to a new URL.

[Link]() Finds the first element that matches the specified select
or.

[Link] 1/6
07/04/2023, 12:04 Box Notes

[Link]() Finds all elements that match the specified selector.

[Link]() Waits for the specified selector to appear on the page.

[Link]() Waits for the page to reach the specified load state.

[Link]() Gets the title of the page.

[Link]() Gets the URL of the page.

[Link]() Navigates the page back in history.

[Link]() Navigates the page forward in history.

[Link]() Reloads the page.

[Link]() Closes the page.

[Link]() Sets the size of the viewport.

[Link]() Sets extra HTTP headers to be sent with every request.

[Link]() Enables or disables request interception.

[Link]() Enables or disables offline mode.

[Link]() Intercepts network requests and invokes the route handl


er.

[Link]() Sets the user agent for the page.

[Link]() Waits for the page to finish navigating to a new URL.

[Link]() Waits for a popup window to appear.

[Link]() Waits for a download to finish.

[Link]() Executes a JavaScript function in the page context.

[Link]() Evaluates a JavaScript expression in the page context an


d returns a handle to the result.

[Link]() Injects a JavaScript file or script into the page context.

[Link] 2/6
07/04/2023, 12:04 Box Notes

[Link]() Exposes a Java object as a JavaScript function in the pag


e context.

[Link]() Simulates a click event on an element.

[Link]() Sets the value of an input element.

[Link]() Selects an option from a dropdown menu.

[Link]() Simulates a hover event on an element.

[Link]() Sets focus on an element.

[Link]() Sends a keyboard event to an element.

[Link]() Types the specified text into an element.

[Link]() Provides methods for simulating keyboard input.

[Link]() Provides methods for simulating mouse input.

[Link]() Provides methods for simulating touchscreen input.

[Link]() Gets the inner text content of an element.

[Link]() Gets the value of the specified attribute for an element.

Method/Property Description

[Link](options: Browser Creates a new browser context.


ContextOptions?)

[Link]() Closes the browser.

[Link](): Page Creates a new page in the current context.

[Link](): List<Page> Gets a list of all pages in the current context.

[Link]() Clears all cookies in the current context.

[Link] 3/6
07/04/2023, 12:04 Box Notes

[Link](cookies: L Adds cookies to the current context.


ist<Cookie>)

[Link]() Clears all permissions in the current context.

[Link](geolo Sets the geolocation for the current context.


cation: Geolocation)

[Link](name: Exposes a Java object as a JavaScript function in the curr


String, callback: BindingCallback) ent context.

[Link](options: BrowserT Launches a new browser instance.


[Link]?)

[Link](endpoi Connects to an existing browser instance using the Chro


ntURL: String) me DevTools Protocol.

Method/Property Description

[Link]() Returns a BrowserType instance for Chromium.

[Link]() Returns a BrowserType instance for Firefox.

[Link]() Returns a BrowserType instance for WebKit.

[Link]().register(name: S Registers a new selector engine with the specified name


tring, script: String) and JavaScript script.

[Link]().register(name: S Registers a new selector engine with the specified name


tring, scriptPath: Path) and JavaScript script file.

[Link]().register(name: S Registers a new selector engine with the specified name


tring, script: URL) and JavaScript script URL.

Method Description

[Link]() Creates a new browser context.

[Link]() Creates a new page in the current context.

[Link] 4/6
07/04/2023, 12:04 Box Notes

[Link]() Navigates the current page to a new URL.

[Link]() Finds the first element that matches the specified select
or.

[Link]() Finds all elements that match the specified selector.

[Link]() Gets the inner text content of an element.

[Link]() Gets the value of the specified attribute for an element.

[Link]() Simulates a click event on the element.

[Link]() Sets the value of an input element.

[Link]() Selects an option from a dropdown menu.

[Link]() Simulates a hover event on the element.

[Link]() Sets focus on the element.

[Link]() Sends a keyboard event to the element.

[Link]() Types the specified text into the element.

[Link]() Returns true if the element is visible on the page.

[Link]() Returns true if the element is disabled.

[Link]() Returns true if the element is editable.

[Link]() Returns the bounding box of the element.

[Link]() Waits for the specified selector to appear on the page.

[Link]() Waits for the page to finish loading.

[Link]() Takes a screenshot of the current page.

[Link] 5/6
07/04/2023, 12:04 Box Notes

[Link] 6/6

You might also like