-
-
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.
feat(java): ✨ added shadow root support
- Loading branch information
Showing
6 changed files
with
579 additions
and
401 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
85 changes: 85 additions & 0 deletions
85
core-java/src/test/java/io/github/boykaframework/testng/ui/theinternet/ShadowRootTest.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,85 @@ | ||
/* | ||
* 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.theinternet; | ||
|
||
import static io.github.boykaframework.actions.device.DeviceActions.onDevice; | ||
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.manager.ParallelSession.clearSession; | ||
import static io.github.boykaframework.manager.ParallelSession.createSession; | ||
import static io.github.boykaframework.testng.ui.theinternet.pages.ShadowRootPage.shadowRootPage; | ||
|
||
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; | ||
|
||
/** | ||
* Login Test class. | ||
* | ||
* @author Wasiq Bhamla | ||
* @since 16-Sept-2023 | ||
*/ | ||
public class ShadowRootTest { | ||
private static final String URL = "https://www.htmlelements.com/demos/menu/shadow-dom/index.htm"; | ||
|
||
/** | ||
* Setup test method to take screenshot after each test method. | ||
*/ | ||
@AfterMethod | ||
public void afterMethod (final ITestResult result) { | ||
if (!result.isSuccess ()) { | ||
onWindow ().takeScreenshot (); | ||
} | ||
} | ||
|
||
/** | ||
* Setup test class by initialising driver. | ||
* | ||
* @param platformType Application type | ||
* @param driverKey Driver config key | ||
*/ | ||
@BeforeClass (description = "Setup test class") | ||
@Parameters ({ "platformType", "driverKey" }) | ||
public void setupClass (final PlatformType platformType, final String driverKey) { | ||
createSession (platformType, driverKey); | ||
navigate ().to (URL); | ||
} | ||
|
||
/** | ||
* Tear down test class by closing driver. | ||
*/ | ||
@AfterClass (description = "Tear down test class") | ||
public void tearDownClass () { | ||
onDevice ().stopRecording (); | ||
clearSession (); | ||
} | ||
|
||
@Test (description = "Test Login Flow") | ||
public void testLogin () { | ||
withMouse (shadowRootPage ().getMenu ("Encoding")).click (); | ||
withMouse (shadowRootPage ().getMenuItem ("Encoding", "Encode in UTF-8")).click (); | ||
|
||
withMouse (shadowRootPage ().getMenu ("Encoding")).click (); | ||
withMouse (shadowRootPage ().getMenuItem ("Encoding", "Encode in UTF-8")).verifyProperty ("checked") | ||
.isEqualTo ("true"); | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
...va/src/test/java/io/github/boykaframework/testng/ui/theinternet/pages/ShadowRootPage.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,85 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2025, 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.theinternet.pages; | ||
|
||
import static java.text.MessageFormat.format; | ||
import static org.openqa.selenium.By.cssSelector; | ||
import static org.openqa.selenium.By.tagName; | ||
|
||
import io.github.boykaframework.builders.Locator; | ||
import lombok.Getter; | ||
|
||
/** | ||
* Shadow example page. | ||
* | ||
* @author Wasiq Bhamla | ||
* @since 13-Jan-2025 | ||
*/ | ||
@Getter | ||
public class ShadowRootPage { | ||
private static final ShadowRootPage SHADOW_ROOT_PAGE = new ShadowRootPage (); | ||
|
||
/** | ||
* Gets the page instance. | ||
* | ||
* @return Page instance | ||
*/ | ||
public static ShadowRootPage shadowRootPage () { | ||
return SHADOW_ROOT_PAGE; | ||
} | ||
|
||
private final Locator smartMenu = Locator.buildLocator () | ||
.name ("Smart Menu") | ||
.web (tagName ("smart-ui-menu")) | ||
.shadowRoot (true) | ||
.build (); | ||
|
||
private ShadowRootPage () { | ||
// Singleton class | ||
} | ||
|
||
/** | ||
* Gets menu. | ||
* | ||
* @param menuName Menu name | ||
* | ||
* @return Locator. | ||
*/ | ||
public Locator getMenu (final String menuName) { | ||
return Locator.buildLocator () | ||
.name (menuName) | ||
.parent (this.smartMenu) | ||
.web (cssSelector (format ("smart-menu-items-group[label=\"{0}\"]", menuName))) | ||
.build (); | ||
} | ||
|
||
/** | ||
* Gets menu item from the menu. | ||
* | ||
* @param menuName Menu name | ||
* @param itemName Item name | ||
* | ||
* @return Locator. | ||
*/ | ||
public Locator getMenuItem (final String menuName, final String itemName) { | ||
return Locator.buildLocator () | ||
.name (itemName) | ||
.parent (getMenu (menuName)) | ||
.web (cssSelector (format ("smart-menu-item[label=\"{0}\"]", itemName))) | ||
.build (); | ||
} | ||
} |
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.