Skip to content

Commit 14615c9

Browse files
committed
added test examples for programmatic click and drag and drop actions
1 parent f4f0100 commit 14615c9

1 file changed

Lines changed: 29 additions & 2 deletions

File tree

src/test/java/io/github/mfaisalkhatri/tests/ClickOperationTests.java

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,35 @@ public void testDragAndDropActions () {
142142
this.page.navigate ("https://the-internet.herokuapp.com/");
143143
this.page.getByRole (AriaRole.LINK, new Page.GetByRoleOptions ().setName ("Drag and Drop"))
144144
.click ();
145-
this.page.locator ("#column-a").dragTo (this.page.locator ("#column-b"));
146-
assertThat(this.page.locator ("#column-a")).containsText ("B");
145+
this.page.locator ("#column-a")
146+
.dragTo (this.page.locator ("#column-b"));
147+
assertThat (this.page.locator ("#column-a")).containsText ("B");
148+
149+
}
150+
151+
@Test
152+
public void testDragAndDropManually () {
153+
this.page.navigate ("https://the-internet.herokuapp.com/");
154+
this.page.getByRole (AriaRole.LINK, new Page.GetByRoleOptions ().setName ("Drag and Drop"))
155+
.click ();
156+
this.page.locator ("#column-a")
157+
.hover ();
158+
this.page.mouse ()
159+
.down ();
160+
this.page.locator ("#column-b")
161+
.hover ();
162+
this.page.mouse ()
163+
.up ();
164+
assertThat (this.page.locator ("#column-a")).containsText ("B");
165+
}
166+
167+
@Test
168+
public void testProgrammaticClick () {
169+
this.page.navigate ("https://the-internet.herokuapp.com/");
170+
this.page.getByRole (AriaRole.LINK, new Page.GetByRoleOptions ().setName ("Checkboxes"))
171+
.dispatchEvent ("click");
172+
173+
assertThat (this.page.getByRole (AriaRole.HEADING)).containsText ("Checkboxes");
147174

148175
}
149176

0 commit comments

Comments
 (0)