-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added example code for mouse hover (#65)
* added example code to perform mouse hover and updated readme * updated dependency version in pom.xml * formatted code * added code to close browser and playwright sessions gracefully using close() method * updated testng xml files
- Loading branch information
1 parent
d410bef
commit 608f781
Showing
13 changed files
with
118 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/test/java/io/github/mfaisalkhatri/tests/MouseHoverTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package io.github.mfaisalkhatri.tests; | ||
|
||
import com.microsoft.playwright.*; | ||
import com.microsoft.playwright.options.AriaRole; | ||
import org.testng.annotations.AfterClass; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.Test; | ||
|
||
import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat; | ||
|
||
public class MouseHoverTest { | ||
|
||
private Playwright playwright; | ||
private Page page; | ||
|
||
|
||
@BeforeClass | ||
public void setup() { | ||
this.playwright = Playwright.create(); | ||
final Browser browser = playwright.chromium().launch(new BrowserType.LaunchOptions().setHeadless(false).setChannel("chrome")); | ||
this.page = browser.newPage(); | ||
} | ||
|
||
@Test | ||
public void testMouseHover() { | ||
page.navigate("https://the-internet.herokuapp.com/hovers"); | ||
Locator firstImage = page.locator("#content div.figure:nth-child(3)"); | ||
firstImage.hover(); | ||
Locator userNameText = page.getByRole(AriaRole.HEADING, new Page.GetByRoleOptions().setName("name: user1")); | ||
assertThat(userNameText).hasText("name: user1"); | ||
} | ||
|
||
@AfterClass | ||
public void tearDown() { | ||
this.page.close(); | ||
this.playwright.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> | ||
<suite name="Playwright demo test suite " > | ||
<test name="Mouse hover demo on Chrome"> | ||
<classes> | ||
<class name="io.github.mfaisalkhatri.tests.MouseHoverTest"> | ||
<methods> | ||
<include name="testMouseHover"/> | ||
</methods> | ||
</class> | ||
</classes> | ||
</test> | ||
</suite> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> | ||
<suite name="Playwright Demo Tests" parallel="tests"> | ||
<test name="Web automation tests using Playwright on Chrome"> | ||
<classes> | ||
<class name="io.github.mfaisalkhatri.tests.PlaywrightDemoTests"> | ||
<methods> | ||
<include name="testOnChromeHeadless"/> | ||
<include name="testOnChrome"/> | ||
<include name="testOnChromeSlowMo"/> | ||
<include name="testBrowserNavigation"/> | ||
</methods> | ||
</class> | ||
</classes> | ||
</test> | ||
<test name="Web automation tests using Playwright on Firefox"> | ||
<classes> | ||
<class name="io.github.mfaisalkhatri.tests.PlaywrightDemoTests"> | ||
<methods> | ||
<include name="testOnFirefoxHeadless"/> | ||
<include name="testOnFirefox"/> | ||
<include name="testOnFirefoxSlowMo"/> | ||
</methods> | ||
</class> | ||
</classes> | ||
</test> | ||
<test name="Web automation tests using Playwright on Edge"> | ||
<classes> | ||
<class name="io.github.mfaisalkhatri.tests.PlaywrightDemoTests"> | ||
<methods> | ||
<include name="testOnEdge"/> | ||
</methods> | ||
</class> | ||
</classes> | ||
</test> | ||
</suite> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters