-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(java): 🐛 fixed issue when clicking hovered element
- Loading branch information
Showing
19 changed files
with
244 additions
and
184 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
64 changes: 64 additions & 0 deletions
64
core-java/src/test/java/io/github/boykaframework/testng/ui/ecomm/AddCartTest.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,64 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2024, Boyka Framework | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
*/ | ||
|
||
package io.github.boykaframework.testng.ui.ecomm; | ||
|
||
import static io.github.boykaframework.actions.drivers.NavigateActions.navigate; | ||
import static io.github.boykaframework.actions.drivers.WindowActions.onWindow; | ||
import static io.github.boykaframework.actions.elements.ClickableActions.withMouse; | ||
import static io.github.boykaframework.actions.elements.ElementActions.onElement; | ||
import static io.github.boykaframework.manager.ParallelSession.clearSession; | ||
import static io.github.boykaframework.manager.ParallelSession.createSession; | ||
import static io.github.boykaframework.testng.ui.ecomm.pages.HomePage.homePage; | ||
|
||
import io.github.boykaframework.enums.PlatformType; | ||
import org.testng.ITestResult; | ||
import org.testng.annotations.AfterClass; | ||
import org.testng.annotations.AfterMethod; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.Parameters; | ||
import org.testng.annotations.Test; | ||
|
||
public class AddCartTest { | ||
@AfterMethod | ||
public void afterMethod (final ITestResult result) { | ||
if (!result.isSuccess ()) { | ||
onWindow ().takeScreenshot (); | ||
} | ||
} | ||
|
||
@BeforeClass | ||
@Parameters ({ "platformType", "driverKey" }) | ||
public void setupTestClass (final PlatformType platformType, final String chromeConfig) { | ||
createSession (platformType, chromeConfig); | ||
} | ||
|
||
@AfterClass | ||
public void tearDownClass () { | ||
clearSession (); | ||
} | ||
|
||
@Test | ||
public void testAddCart () { | ||
navigate ().to ("https://ecommerce-playground.lambdatest.io/"); | ||
withMouse (homePage ().getProduct1 ()).hover (); | ||
withMouse (homePage ().getAddToCart ()).click (); | ||
withMouse (homePage ().getCloseToast ()).click (); | ||
|
||
onElement (homePage ().getCartCount ()).verifyText () | ||
.isEqualTo ("1"); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
core-java/src/test/java/io/github/boykaframework/testng/ui/ecomm/pages/HomePage.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,63 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2024, Boyka Framework | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
*/ | ||
|
||
package io.github.boykaframework.testng.ui.ecomm.pages; | ||
|
||
import static org.openqa.selenium.By.cssSelector; | ||
|
||
import io.github.boykaframework.builders.Locator; | ||
import lombok.Getter; | ||
|
||
/** | ||
* E-Comm Home Page | ||
* | ||
* @author Wasiq Bhamla | ||
* @since 02-Oct-2024 | ||
*/ | ||
@Getter | ||
public class HomePage { | ||
private static final HomePage HOME_PAGE = new HomePage (); | ||
|
||
/** | ||
* Gets the Home page instance | ||
* | ||
* @return Home page | ||
*/ | ||
public static HomePage homePage () { | ||
return HOME_PAGE; | ||
} | ||
|
||
private final Locator addToCart = Locator.buildLocator () | ||
.name ("Add To Cart") | ||
.web (cssSelector ("div.product-action button[title=\"Add to Cart\"]")) | ||
.build (); | ||
private final Locator cartCount = Locator.buildLocator () | ||
.name ("Cart Count") | ||
.web (cssSelector ("div.cart-icon span")) | ||
.build (); | ||
private final Locator closeToast = Locator.buildLocator () | ||
.name ("Close Toast") | ||
.web (cssSelector ("button[data-dismiss=\"toast\"]")) | ||
.build (); | ||
private final Locator product1 = Locator.buildLocator () | ||
.web (cssSelector ("div.entry-section div[aria-label=\"1 / 10\"] div.product-thumb-top")) | ||
.name ("Product 1") | ||
.build (); | ||
|
||
private HomePage () { | ||
// Utility class. | ||
} | ||
} |
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
Oops, something went wrong.