This article will be about how we can double-click on playwright java. Using the dblClick() method from the page, we can double-click any element on the web page.
- For example, let us try to double-click the "Click Me" and take the text content.
- It should print "Welcome To ProgramsBuzz."
try (Playwright playwright = Playwright.create()) {
Browser browser = playwright.chromium().launch(new BrowserType.LaunchOptions().setHeadless(false));
Page page = browser.newPage();
page.navigate("C:\\Users\\arili\\git\\Assignments\\Selenium\\dbl.html");
Locator textClick = page.locator("//*[@id='heading']");
textClick.dblclick();
String textContent = page.locator("//*[@id='heading']").textContent();
System.out.println(textContent);
- We can see that it has double-clicked the element and fetched the changed text, which is printed.
- Log in to post comments