Skip to content

Commit 3f3f55e

Browse files
authored
feat(java): ✨ added experimental options support for web (#909)
1 parent 77d283a commit 3f3f55e

File tree

9 files changed

+40
-14
lines changed

9 files changed

+40
-14
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
<a href="https://central.sonatype.com/artifact/io.github.boykaframework/boyka-framework">
2424
<img src="https://img.shields.io/maven-central/v/io.github.boykaframework/boyka-framework.svg?style=for-the-badge" alt="Maven Central" />
2525
</a>
26-
<a href="https://github.com/BoykaFramework/boyka-framework/releases/tag/v1.2.0">
27-
<img src="https://img.shields.io/github/downloads/BoykaFramework/boyka-framework/v1.2.0/total?color=brightgreen&label=Downloads%20for%20v1.2.0&logo=GitHub&style=for-the-badge" alt="GitHub releases" />
26+
<a href="https://github.com/BoykaFramework/boyka-framework/releases/tag/v2.1.1">
27+
<img src="https://img.shields.io/github/downloads/BoykaFramework/boyka-framework/v2.1.1/total?color=brightgreen&label=Downloads%20for%20v2.1.1&logo=GitHub&style=for-the-badge" alt="GitHub releases" />
2828
</a>
2929
<a href="https://github.com/BoykaFramework/boyka-framework/blob/master/LICENSE">
3030
<img src="https://img.shields.io/github/license/BoykaFramework/boyka-framework.svg?style=for-the-badge" alt="license" />

core-java/src/main/java/io/github/boykaframework/config/ui/web/WebSetting.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public class WebSetting {
4646
private List<String> browserOptions;
4747
private Map<String, Object> capabilities;
4848
private Dimension customSize = new Dimension (1920, 1080);
49+
private Map<String, Object> experimentalOptions;
4950
private boolean headless = true;
5051
private boolean highlight = false;
5152
private String host;

core-java/src/main/java/io/github/boykaframework/manager/WebDriverManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ private FirefoxOptions getFirefoxOptions (final WebSetting webSetting) {
128128
final var options = new FirefoxOptions ();
129129
ofNullable (webSetting.getPlatform ()).ifPresent (options::setPlatformName);
130130
ofNullable (webSetting.getBrowserOptions ()).ifPresent (l -> l.forEach (options::addArguments));
131+
ofNullable (webSetting.getExperimentalOptions ()).ifPresent (l -> l.forEach (options::addPreference));
131132
if (webSetting.getTarget () == LOCAL && isNull (webSetting.getCapabilities ())) {
132133
options.setBrowserVersion (webSetting.getVersion ());
133134
}
@@ -202,6 +203,7 @@ private <T extends ChromiumOptions<T>> void setCommonBrowserOptions (final T opt
202203
options.addArguments ("--disable-gpu");
203204
options.addArguments ("--disable-dev-shm-usage");
204205
ofNullable (webSetting.getBrowserOptions ()).ifPresent (l -> l.forEach (options::addArguments));
206+
ofNullable (webSetting.getExperimentalOptions ()).ifPresent (l -> l.forEach (options::setExperimentalOption));
205207
if (webSetting.isHeadless ()) {
206208
options.addArguments (HEADLESS);
207209
}

core-java/src/test/java/io/github/boykaframework/testng/ui/ecomm/AddCartTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import static io.github.boykaframework.actions.drivers.WindowActions.onWindow;
2121
import static io.github.boykaframework.actions.elements.ClickableActions.withMouse;
2222
import static io.github.boykaframework.actions.elements.ElementActions.onElement;
23+
import static io.github.boykaframework.actions.elements.TextBoxActions.onTextBox;
2324
import static io.github.boykaframework.manager.ParallelSession.clearSession;
2425
import static io.github.boykaframework.manager.ParallelSession.createSession;
2526
import static io.github.boykaframework.testng.ui.ecomm.pages.HomePage.homePage;
@@ -54,6 +55,10 @@ public void tearDownClass () {
5455
@Test
5556
public void testAddCart () {
5657
navigate ().to ("https://ecommerce-playground.lambdatest.io/");
58+
59+
onTextBox (homePage ().getSearch ()).enterText ("HTC");
60+
withMouse (homePage ().getSearchButton ()).click ();
61+
5762
withMouse (homePage ().getProduct1 ()).scrollIntoView ();
5863
withMouse (homePage ().getProduct1 ()).hover ();
5964
withMouse (homePage ().getAddToCart ()).click ();

core-java/src/test/java/io/github/boykaframework/testng/ui/ecomm/pages/HomePage.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package io.github.boykaframework.testng.ui.ecomm.pages;
1818

1919
import static org.openqa.selenium.By.cssSelector;
20+
import static org.openqa.selenium.By.name;
2021

2122
import io.github.boykaframework.builders.Locator;
2223
import lombok.Getter;
@@ -40,22 +41,30 @@ public static HomePage homePage () {
4041
return HOME_PAGE;
4142
}
4243

43-
private final Locator addToCart = Locator.buildLocator ()
44+
private final Locator addToCart = Locator.buildLocator ()
4445
.name ("Add To Cart")
4546
.web (cssSelector ("div.product-action button[title=\"Add to Cart\"]"))
4647
.build ();
47-
private final Locator cartCount = Locator.buildLocator ()
48+
private final Locator cartCount = Locator.buildLocator ()
4849
.name ("Cart Count")
4950
.web (cssSelector ("div.cart-icon span"))
5051
.build ();
51-
private final Locator closeToast = Locator.buildLocator ()
52+
private final Locator closeToast = Locator.buildLocator ()
5253
.name ("Close Toast")
5354
.web (cssSelector ("button[data-dismiss=\"toast\"]"))
5455
.build ();
55-
private final Locator product1 = Locator.buildLocator ()
56-
.web (cssSelector ("div.entry-section div[aria-label=\"1 / 10\"] div.product-thumb-top"))
56+
private final Locator product1 = Locator.buildLocator ()
57+
.web (cssSelector ("img[title=\"HTC Touch HD\"]"))
5758
.name ("Product 1")
5859
.build ();
60+
private final Locator search = Locator.buildLocator ()
61+
.name ("Sear Box")
62+
.web (name ("search"))
63+
.build ();
64+
private final Locator searchButton = Locator.buildLocator ()
65+
.name ("Search button")
66+
.web (cssSelector ("div.search-button button"))
67+
.build ();
5968

6069
private HomePage () {
6170
// Utility class.

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "2.1.0",
2+
"version": "2.1.1",
33
"npmClient": "pnpm",
44
"useWorkspace": false,
55
"changelog": {

pnpm-lock.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

website/docs/framework-docs/guides/config/configuration.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,8 @@ See the example in [sample configuration file](#config-sample).
447447
| `resize` | How to resize the window initial state | [`WindowResizeType`](#window-resize-type) | `WindowResizeType.NORMAL` |
448448
| `custom_size` | Custom window size, when `resize` option is selected as `CUSTOM` | `Dimension` | `1920x1080` |
449449
| `page_load_strategy` | Page loading strategy (all in capital letters) | [`PageLoadStrategy`](https://www.selenium.dev/documentation/webdriver/drivers/options/#pageloadstrategy) | `NORMAL` |
450+
| `browser_options` | An array of browser specific arguments | `string[]` | `null` |
451+
| `experimental_options` | A key-value pair of Browsers Experimental options | `Map<string, object>` | `null` |
450452

451453
:::info
452454
You can use Environment variables for `user_name` and `password` by using `${env:ENV_NAME}` format
@@ -456,6 +458,12 @@ You can use Environment variables for `user_name` and `password` by using `${env
456458
When you use Boyka command line assistant to configure your test to run on any Cloud providers using `boyka config [web | api | android | ios] [config_name]` command, then it is **MANDATORY** to provide Environment variable names when prompted for user name and password
457459
:::
458460

461+
:::warning
462+
Browser options and Experimental options is not supported for **Safari browser**.
463+
464+
Please raise a [new feature request](https://github.com/BoykaFramework/boyka-framework/issues/new/choose) along with sample example test and options support that is required
465+
:::
466+
459467
#### Mobile Configuration {#mobile-config}
460468

461469
| Property | Description | Type | Default |

website/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "website",
3-
"version": "1.2.0",
3+
"version": "2.1.1",
44
"private": true,
55
"scripts": {
66
"docusaurus": "docusaurus",
@@ -45,5 +45,6 @@
4545
"last 1 firefox version",
4646
"last 1 safari version"
4747
]
48-
}
48+
},
49+
"packageManager": "[email protected]"
4950
}

0 commit comments

Comments
 (0)