-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(java): ✨ added mouse actions and added test cases (#116)
* feat(java): ✨ add method to verify header and update documentation * feat(java): ✨ added mouse actions and added test cases
- Loading branch information
1 parent
8e0757a
commit a0ec76f
Showing
4 changed files
with
219 additions
and
0 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
67 changes: 67 additions & 0 deletions
67
core-java/src/test/java/com/github/wasiqb/boyka/testng/web/TestMouseAction.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,67 @@ | ||
package com.github.wasiqb.boyka.testng.web; | ||
|
||
import static com.github.wasiqb.boyka.actions.DriverActions.navigateTo; | ||
import static com.github.wasiqb.boyka.actions.MouseActions.clickOn; | ||
import static com.github.wasiqb.boyka.actions.MouseActions.dragDropTo; | ||
import static com.github.wasiqb.boyka.actions.MouseActions.hoverOn; | ||
import static com.github.wasiqb.boyka.actions.VerifyDriverActions.verifyBrowserUrl; | ||
import static com.github.wasiqb.boyka.actions.VerifyElementActions.verifyTextOf; | ||
import static com.github.wasiqb.boyka.manager.DriverManager.closeDriver; | ||
import static com.github.wasiqb.boyka.manager.DriverManager.createDriver; | ||
import static com.github.wasiqb.boyka.testng.web.pages.MouseEvent.mouseEvent; | ||
|
||
import com.github.wasiqb.boyka.enums.ApplicationType; | ||
import org.testng.annotations.AfterClass; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.Parameters; | ||
import org.testng.annotations.Test; | ||
|
||
public class TestMouseAction { | ||
|
||
private static final String URL = "https://the-internet.herokuapp.com/"; | ||
|
||
/** | ||
* Setup test class by initialising driver. | ||
* | ||
* @param appType Application type | ||
* @param driverKey Driver config key | ||
*/ | ||
@BeforeClass (description = "Setup test class") | ||
@Parameters ({ "appType", "driverKey" }) | ||
public void setupTestClass (final ApplicationType appType, final String driverKey) { | ||
createDriver (appType, driverKey); | ||
} | ||
|
||
/** | ||
* Tear down test class by closing driver. | ||
*/ | ||
@AfterClass (description = "Tear down test class") | ||
public void tearDownTestClass () { | ||
closeDriver (); | ||
} | ||
|
||
/** | ||
* Test dragAndDrop functionality. | ||
*/ | ||
@Test (description = "Test dragAndDrop functionality", priority = 1) | ||
public void testDragAndDrop () { | ||
navigateTo (URL); | ||
verifyBrowserUrl ().startsWith (URL); | ||
clickOn (mouseEvent ().getDragAndDropLink ()); | ||
dragDropTo (mouseEvent ().getDraggable (), mouseEvent ().getDroppable ()); | ||
verifyTextOf (mouseEvent ().getDragAndDropResult ()).isEqualTo ("B"); | ||
} | ||
|
||
/** | ||
* Test hover functionality. | ||
*/ | ||
@Test (description = "Test hover functionality", priority = 2) | ||
public void testMouseHover () { | ||
navigateTo (URL); | ||
verifyBrowserUrl ().startsWith (URL); | ||
clickOn (mouseEvent ().getHoverLink ()); | ||
hoverOn (mouseEvent ().getHoverImage ()); | ||
verifyTextOf (mouseEvent ().getHoverResult ()).isEqualTo ("name: user1"); | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
core-java/src/test/java/com/github/wasiqb/boyka/testng/web/pages/MouseEvent.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,36 @@ | ||
package com.github.wasiqb.boyka.testng.web.pages; | ||
|
||
import static com.github.wasiqb.boyka.builders.Locator.buildLocator; | ||
import static org.openqa.selenium.By.id; | ||
import static org.openqa.selenium.By.xpath; | ||
|
||
import com.github.wasiqb.boyka.builders.Locator; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class MouseEvent { | ||
|
||
public static MouseEvent mouseEvent () { | ||
return new MouseEvent (); | ||
} | ||
|
||
private final Locator dragAndDropLink = buildLocator ().web ( | ||
xpath ("//div[@id='content']//a[text()='Drag and Drop']")) | ||
.build (); | ||
private final Locator dragAndDropResult = buildLocator ().web (xpath ("//div[@id='column-b']/header")) | ||
.build (); | ||
private final Locator draggable = buildLocator ().web (id ("column-a")) | ||
.build (); | ||
private final Locator droppable = buildLocator ().web (id ("column-b")) | ||
.build (); | ||
private final Locator hoverImage = buildLocator ().web (xpath ("(//div[@class='figure'])[1]")) | ||
.build (); | ||
private final Locator hoverLink = buildLocator ().web (xpath ("//div[@id='content']//a[text()='Hovers']")) | ||
.build (); | ||
private final Locator hoverResult = buildLocator ().web (xpath ("(//div[@class='figure'])[1]//h5")) | ||
.build (); | ||
|
||
private MouseEvent () { | ||
|
||
} | ||
} |
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