File tree Expand file tree Collapse file tree
src/test/java/io/github/mfaisalkhatri/tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44
55import com .microsoft .playwright .Browser ;
66import com .microsoft .playwright .BrowserType ;
7+ import com .microsoft .playwright .Locator ;
78import com .microsoft .playwright .Page ;
89import com .microsoft .playwright .Playwright ;
910import com .microsoft .playwright .options .AriaRole ;
11+ import com .microsoft .playwright .options .MouseButton ;
1012import org .testng .annotations .AfterClass ;
1113import org .testng .annotations .BeforeClass ;
1214import org .testng .annotations .Test ;
@@ -37,6 +39,18 @@ public void testLeftClick () {
3739 this .page .getByRole (AriaRole .HEADING , new Page .GetByRoleOptions ().setName ("Challenging DOM" ))).isVisible ();
3840 }
3941
42+ @ Test
43+ public void testRightClick () {
44+ this .page .navigate ("https://the-internet.herokuapp.com/context_menu" );
45+ this .page .locator ("#hot-spot" )
46+ .click (new Locator .ClickOptions ().setButton (MouseButton .RIGHT ));
47+ this .page .onDialog (dialog -> {
48+ String alertText = dialog .message ();
49+
50+ assert alertText .equals ("You selected a context menu" );
51+ dialog .accept ();
52+ });
53+ }
4054
4155 @ AfterClass
4256 public void tearDown () {
You can’t perform that action at this time.
0 commit comments