Skip to content

Commit 8e626a5

Browse files
authored
feat(java): ⚡ simplified cloud configurations (#373)
1 parent 13ab611 commit 8e626a5

File tree

14 files changed

+256
-139
lines changed

14 files changed

+256
-139
lines changed

.github/workflows/codesee-arch-diagram.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
push:
55
branches:
66
- main
7+
- develop
8+
- staging
79
pull_request_target:
810
types: [opened, synchronize, reopened]
911

README.md

Lines changed: 72 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,7 @@ This is the configuration file for Boyka Framework named `boyka-config.json` sto
136136
},
137137
"test_browserstack_chrome": {
138138
"browser": "REMOTE",
139-
"cloud": "BROWSER_STACK",
140-
"protocol": "HTTPS",
141-
"host": "hub-cloud.browserstack.com",
139+
"target": "BROWSER_STACK",
142140
"user_name": "${env:BS_USER}",
143141
"password": "${env:BS_KEY}",
144142
"capabilities": {
@@ -154,8 +152,7 @@ This is the configuration file for Boyka Framework named `boyka-config.json` sto
154152
},
155153
"test_selenium_grid": {
156154
"browser": "REMOTE",
157-
"cloud": "NONE",
158-
"host": "localhost",
155+
"target": "LOCAL",
159156
"port": "4444",
160157
"capabilities": {
161158
"browserName": "chrome",
@@ -164,9 +161,7 @@ This is the configuration file for Boyka Framework named `boyka-config.json` sto
164161
},
165162
"test_lambda_test_chrome": {
166163
"browser": "REMOTE",
167-
"cloud": "LAMBDA_TEST",
168-
"protocol": "HTTPS",
169-
"host": "hub.lambdatest.com",
164+
"target": "LAMBDA_TEST_WEB",
170165
"user_name": "${env:LT_USER}",
171166
"password": "${env:LT_KEY}",
172167
"capabilities": {
@@ -186,10 +181,8 @@ This is the configuration file for Boyka Framework named `boyka-config.json` sto
186181
"mobile": {
187182
"test_local_sauce_android": {
188183
"server": {
189-
"protocol": "HTTP",
190-
"host": "127.0.0.1",
184+
"target": "LOCAL",
191185
"port": 4723,
192-
"base_path": "/wd/hub",
193186
"session_override": true,
194187
"driver": "UI_AUTOMATOR",
195188
"allow_insecure": [
@@ -220,12 +213,9 @@ This is the configuration file for Boyka Framework named `boyka-config.json` sto
220213
},
221214
"test_bs_android": {
222215
"server": {
223-
"cloud": "BROWSER_STACK",
224-
"protocol": "HTTPS",
225-
"host": "hub-cloud.browserstack.com",
216+
"target": "BROWSER_STACK",
226217
"user_name": "${env:BS_USER}",
227218
"password": "${env:BS_KEY}",
228-
"base_path": "/wd/hub",
229219
"driver": "UI_AUTOMATOR"
230220
},
231221
"device": {
@@ -253,12 +243,43 @@ This is the configuration file for Boyka Framework named `boyka-config.json` sto
253243
}
254244
}
255245
},
246+
"test_lt_android": {
247+
"server": {
248+
"target": "LAMBDA_TEST_MOBILE",
249+
"user_name": "${env:LT_USER}",
250+
"password": "${env:LT_KEY}",
251+
"driver": "UI_AUTOMATOR"
252+
},
253+
"device": {
254+
"type": "CLOUD",
255+
"application": {
256+
"install_timeout": 180,
257+
"wait_activity": "com.swaglabsmobileapp.MainActivity"
258+
},
259+
"ignore_unimportant_views": true,
260+
"capabilities": {
261+
"platformName": "Android",
262+
"deviceName": "Pixel 5",
263+
"platformVersion": "11",
264+
"app": "${env:LT_APP_ANDROID}",
265+
"project": "LambdaTest Android Project",
266+
"build": "Test LambdaTest Build",
267+
"name": "Test LambdaTest Session",
268+
"devicelog": true,
269+
"network": true,
270+
"visual": true,
271+
"video": true,
272+
"autoGrantPermissions": true,
273+
"autoAcceptAlerts": true,
274+
"isRealMobile": true,
275+
"w3c": true
276+
}
277+
}
278+
},
256279
"test_local_sauce_ios": {
257280
"server": {
258-
"protocol": "HTTP",
259-
"host": "127.0.0.1",
281+
"target": "LOCAL",
260282
"port": 4724,
261-
"base_path": "/wd/hub",
262283
"session_override": true,
263284
"driver": "XCUI",
264285
"allow_insecure": [
@@ -294,12 +315,9 @@ This is the configuration file for Boyka Framework named `boyka-config.json` sto
294315
},
295316
"test_bs_ios": {
296317
"server": {
297-
"cloud": "BROWSER_STACK",
298-
"protocol": "HTTPS",
299-
"host": "hub-cloud.browserstack.com",
318+
"target": "BROWSER_STACK",
300319
"user_name": "${env:BS_USER}",
301320
"password": "${env:BS_KEY}",
302-
"base_path": "/wd/hub",
303321
"driver": "XCUI"
304322
},
305323
"device": {
@@ -325,6 +343,38 @@ This is the configuration file for Boyka Framework named `boyka-config.json` sto
325343
"appiumLogs": true
326344
}
327345
}
346+
},
347+
"test_lt_ios": {
348+
"server": {
349+
"target": "LAMBDA_TEST_MOBILE",
350+
"user_name": "${env:LT_USER}",
351+
"password": "${env:LT_KEY}",
352+
"driver": "XCUI"
353+
},
354+
"device": {
355+
"type": "CLOUD",
356+
"application": {
357+
"install_timeout": 180
358+
},
359+
"ignore_unimportant_views": true,
360+
"capabilities": {
361+
"platformName": "iOS",
362+
"deviceName": "iPhone 14",
363+
"platformVersion": "16",
364+
"app": "${env:LT_APP_IOS}",
365+
"project": "LambdaTest iOS Project",
366+
"build": "Test LambdaTest Build",
367+
"name": "Test LambdaTest Session",
368+
"devicelog": true,
369+
"network": true,
370+
"visual": true,
371+
"video": true,
372+
"autoGrantPermissions": true,
373+
"autoAcceptAlerts": true,
374+
"isRealMobile": true,
375+
"w3c": true
376+
}
377+
}
328378
}
329379
}
330380
},

core-java/src/main/java/com/github/wasiqb/boyka/config/ui/mobile/server/ServerSetting.java

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@
1616

1717
package com.github.wasiqb.boyka.config.ui.mobile.server;
1818

19-
import static com.github.wasiqb.boyka.enums.CloudProviders.NONE;
20-
import static com.github.wasiqb.boyka.enums.Protocol.HTTP;
19+
import static com.github.wasiqb.boyka.enums.TargetProviders.LOCAL;
2120
import static com.github.wasiqb.boyka.utils.StringUtils.interpolate;
2221

2322
import java.util.List;
2423

2524
import com.github.wasiqb.boyka.enums.AutomationType;
26-
import com.github.wasiqb.boyka.enums.CloudProviders;
2725
import com.github.wasiqb.boyka.enums.Protocol;
26+
import com.github.wasiqb.boyka.enums.TargetProviders;
2827
import lombok.Data;
2928

3029
/**
@@ -35,22 +34,22 @@
3534
*/
3635
@Data
3736
public class ServerSetting {
38-
private List<String> allowInsecure;
39-
private AndroidSetting android;
40-
private String appiumPath;
41-
private String basePath;
42-
private CloudProviders cloud = NONE;
43-
private AutomationType driver;
44-
private boolean external;
45-
private String host;
46-
private IOSSetting ios;
47-
private String nodePath;
48-
private String password;
49-
private int port;
50-
private Protocol protocol = HTTP;
51-
private boolean sessionOverride = true;
52-
private int timeout = 30;
53-
private String userName;
37+
private List<String> allowInsecure;
38+
private AndroidSetting android;
39+
private String appiumPath;
40+
private String basePath = "/wd/hub";
41+
private AutomationType driver;
42+
private boolean external;
43+
private String host;
44+
private IOSSetting ios;
45+
private String nodePath;
46+
private String password;
47+
private int port;
48+
private Protocol protocol;
49+
private boolean sessionOverride = true;
50+
private TargetProviders target = LOCAL;
51+
private int timeout = 30;
52+
private String userName;
5453

5554
/**
5655
* Gets cloud password.

core-java/src/main/java/com/github/wasiqb/boyka/config/ui/web/WebSetting.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
import java.util.Map;
2323

2424
import com.github.wasiqb.boyka.enums.Browser;
25-
import com.github.wasiqb.boyka.enums.CloudProviders;
2625
import com.github.wasiqb.boyka.enums.Protocol;
26+
import com.github.wasiqb.boyka.enums.TargetProviders;
2727
import com.github.wasiqb.boyka.enums.WindowResizeType;
2828
import lombok.Data;
2929
import org.openqa.selenium.Dimension;
@@ -38,7 +38,6 @@
3838
public class WebSetting {
3939
private Browser browser = Browser.CHROME;
4040
private Map<String, Object> capabilities;
41-
private CloudProviders cloud = CloudProviders.NONE;
4241
private Dimension customSize = new Dimension (1920, 1080);
4342
private boolean headless = true;
4443
private boolean highlight = false;
@@ -47,6 +46,7 @@ public class WebSetting {
4746
private int port;
4847
private Protocol protocol = HTTP;
4948
private WindowResizeType resize = WindowResizeType.NORMAL;
49+
private TargetProviders target;
5050
private String userName;
5151

5252
/**

core-java/src/main/java/com/github/wasiqb/boyka/enums/CloudProviders.java renamed to core-java/src/main/java/com/github/wasiqb/boyka/enums/TargetProviders.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,38 @@
1616

1717
package com.github.wasiqb.boyka.enums;
1818

19+
import static com.github.wasiqb.boyka.enums.Protocol.HTTP;
20+
import static com.github.wasiqb.boyka.enums.Protocol.HTTPS;
21+
22+
import lombok.AllArgsConstructor;
23+
import lombok.Getter;
24+
1925
/**
2026
* Supported cloud providers.
2127
*
2228
* @author Wasiq Bhamla
2329
* @since 24-Feb-2022
2430
*/
25-
public enum CloudProviders {
31+
@Getter
32+
@AllArgsConstructor
33+
public enum TargetProviders {
2634
/**
2735
* BrowserStack.
2836
*/
29-
BROWSER_STACK,
37+
BROWSER_STACK ("hub-cloud.browserstack.com", HTTPS),
3038
/**
3139
* None.
3240
*/
33-
NONE,
41+
LOCAL ("127.0.0.1", HTTP),
3442
/**
35-
* Lambda Test.
43+
* Lambda Test for Web.
3644
*/
37-
LAMBDA_TEST
45+
LAMBDA_TEST_WEB ("hub.lambdatest.com", HTTPS),
46+
/**
47+
* Lambda Test for Mobile.
48+
*/
49+
LAMBDA_TEST_MOBILE ("mobile-hub.lambdatest.com", HTTPS);
50+
51+
private final String host;
52+
private final Protocol protocol;
3853
}

core-java/src/main/java/com/github/wasiqb/boyka/manager/AndroidManager.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
import com.github.wasiqb.boyka.config.ui.mobile.device.ApplicationSetting;
1313
import com.github.wasiqb.boyka.config.ui.mobile.device.DeviceSetting;
1414
import com.github.wasiqb.boyka.config.ui.mobile.device.VirtualDeviceSetting;
15-
import com.github.wasiqb.boyka.enums.CloudProviders;
1615
import com.github.wasiqb.boyka.enums.DeviceType;
16+
import com.github.wasiqb.boyka.enums.TargetProviders;
1717
import io.appium.java_client.android.AndroidDriver;
1818
import io.appium.java_client.android.options.UiAutomator2Options;
1919

@@ -32,7 +32,7 @@ public void setupDriver () {
3232
.getDriver ();
3333
if (automation == UI_AUTOMATOR) {
3434
setupUiAutomatorDriver (this.mobileSetting.getServer ()
35-
.getCloud ());
35+
.getTarget ());
3636
}
3737
setupAndroidSettings ();
3838
}
@@ -77,15 +77,15 @@ private void setLocalUiAutomatorOptions (final UiAutomator2Options options) {
7777
}
7878

7979
private void setupAndroidSettings () {
80-
final AndroidDriver driver = (AndroidDriver) getSession ().getDriver ();
80+
final var driver = (AndroidDriver) getSession ().getDriver ();
8181
driver.setSetting (IGNORE_UNIMPORTANT_VIEWS, this.settings.isIgnoreUnimportantViews ());
8282
}
8383

84-
private void setupUiAutomatorDriver (final CloudProviders cloudProviders) {
85-
final UiAutomator2Options options = new UiAutomator2Options ();
84+
private void setupUiAutomatorDriver (final TargetProviders targetProviders) {
85+
final var options = new UiAutomator2Options ();
8686
setCommonUiAutomatorOptions (options);
8787
if (this.settings.getType () == CLOUD) {
88-
setupCloudMobileDriver (options, cloudProviders, this.settings);
88+
setupCloudMobileDriver (options, targetProviders, this.settings);
8989
} else {
9090
setLocalUiAutomatorOptions (options);
9191
}

core-java/src/main/java/com/github/wasiqb/boyka/manager/IDriverManager.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
import com.github.wasiqb.boyka.config.ui.mobile.device.ApplicationSetting;
2828
import com.github.wasiqb.boyka.config.ui.mobile.device.DeviceSetting;
29-
import com.github.wasiqb.boyka.enums.CloudProviders;
29+
import com.github.wasiqb.boyka.enums.TargetProviders;
3030
import io.appium.java_client.remote.options.BaseOptions;
3131
import io.appium.java_client.remote.options.SupportsAppOption;
3232

@@ -60,12 +60,13 @@ default <E extends BaseOptions<E>> void setupCloudDriverOptions (final E options
6060
}
6161

6262
default <E extends BaseOptions<E>> void setupCloudMobileDriver (final E options,
63-
final CloudProviders cloudProviders, final DeviceSetting deviceSetting) {
64-
switch (cloudProviders) {
63+
final TargetProviders targetProviders, final DeviceSetting deviceSetting) {
64+
switch (targetProviders) {
6565
case BROWSER_STACK:
6666
setupCloudDriverOptions (options, deviceSetting, "bstack");
6767
break;
68-
case LAMBDA_TEST:
68+
case LAMBDA_TEST_MOBILE:
69+
case LAMBDA_TEST_WEB:
6970
default:
7071
setupCloudDriverOptions (options, deviceSetting, "lt");
7172
break;

core-java/src/main/java/com/github/wasiqb/boyka/manager/IOSManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void setupDriver () {
5151
setCommonCapabilities (options);
5252
if (this.settings.getType () == CLOUD) {
5353
setupCloudMobileDriver (options, this.mobileSetting.getServer ()
54-
.getCloud (), this.settings);
54+
.getTarget (), this.settings);
5555
} else {
5656
setupLocalSimulatorOptions (options);
5757
}

0 commit comments

Comments
 (0)