digital-ai-testing-mcp 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/README.md +18 -13
  2. package/dist/api/browser-inspection.d.ts.map +1 -1
  3. package/dist/api/browser-inspection.js +7 -1
  4. package/dist/api/browser-inspection.js.map +1 -1
  5. package/dist/api/reporting.d.ts +10 -1
  6. package/dist/api/reporting.d.ts.map +1 -1
  7. package/dist/api/reporting.js +30 -9
  8. package/dist/api/reporting.js.map +1 -1
  9. package/dist/api/webdriver.d.ts +61 -3
  10. package/dist/api/webdriver.d.ts.map +1 -1
  11. package/dist/api/webdriver.js +659 -33
  12. package/dist/api/webdriver.js.map +1 -1
  13. package/dist/index.js +1 -0
  14. package/dist/index.js.map +1 -1
  15. package/dist/tools/boilerplate-tools.d.ts +1 -1
  16. package/dist/tools/boilerplate-tools.d.ts.map +1 -1
  17. package/dist/tools/boilerplate-tools.js +155 -52
  18. package/dist/tools/boilerplate-tools.js.map +1 -1
  19. package/dist/tools/inspection-tools.d.ts.map +1 -1
  20. package/dist/tools/inspection-tools.js +217 -23
  21. package/dist/tools/inspection-tools.js.map +1 -1
  22. package/dist/tools/meta-tools.d.ts +7 -1
  23. package/dist/tools/meta-tools.d.ts.map +1 -1
  24. package/dist/tools/meta-tools.js +21 -7
  25. package/dist/tools/meta-tools.js.map +1 -1
  26. package/dist/tools/performance-tools.d.ts.map +1 -1
  27. package/dist/tools/performance-tools.js +6 -1
  28. package/dist/tools/performance-tools.js.map +1 -1
  29. package/dist/tools/reporting-tools.d.ts.map +1 -1
  30. package/dist/tools/reporting-tools.js +4 -2
  31. package/dist/tools/reporting-tools.js.map +1 -1
  32. package/dist/tools/transaction-tools.d.ts.map +1 -1
  33. package/dist/tools/transaction-tools.js +24 -5
  34. package/dist/tools/transaction-tools.js.map +1 -1
  35. package/dist/types/digital-ai.d.ts +8 -0
  36. package/dist/types/digital-ai.d.ts.map +1 -1
  37. package/dist/utils/test-orchestrator.d.ts +2 -0
  38. package/dist/utils/test-orchestrator.d.ts.map +1 -1
  39. package/dist/utils/test-orchestrator.js +2 -0
  40. package/dist/utils/test-orchestrator.js.map +1 -1
  41. package/package.json +3 -1
  42. package/resources/boilerplate/Android-Native/Java JUnit5/AndroidNative-oss-po.java +48 -0
  43. package/resources/boilerplate/Android-Native/Java JUnit5/AndroidNative-oss.java +23 -13
  44. package/resources/boilerplate/Android-Native/Java JUnit5/AndroidNative.java +19 -10
  45. package/resources/boilerplate/Android-Native/Java JUnit5/gradle-oss +4 -1
  46. package/resources/boilerplate/Android-Native/Java JUnit5/maven-oss +7 -1
  47. package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/AndroidNative-po.js +13 -0
  48. package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/AndroidNative.js +17 -11
  49. package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/wdio-oss.conf.js +7 -2
  50. package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/wdio.conf.js +10 -4
  51. package/resources/boilerplate/Android-Native/Python/AndroidNative-oss.py +30 -14
  52. package/resources/boilerplate/Android-Native/Python/AndroidNative.py +21 -5
  53. package/resources/boilerplate/Android-Native/Robot Framework/AndroidNative-oss.robot +28 -11
  54. package/resources/boilerplate/Android-Native/java TestNG/AndroidNative-oss-po.java +48 -0
  55. package/resources/boilerplate/Android-Native/java TestNG/AndroidNative-oss.java +23 -13
  56. package/resources/boilerplate/Android-Native/java TestNG/AndroidNative.java +19 -10
  57. package/resources/boilerplate/Android-Native/java TestNG/gradle-oss +4 -1
  58. package/resources/boilerplate/Android-Native/java TestNG/maven-oss +7 -1
  59. package/resources/boilerplate/iOS-Native/NodeJS (WebDriver)/iOSNative-po.js +13 -0
  60. package/resources/boilerplate/iOS-Native/NodeJS (WebDriver)/iOSNative.js +17 -11
  61. package/resources/boilerplate/iOS-Native/NodeJS (WebDriver)/wdio-oss.conf.js +4 -1
  62. package/resources/boilerplate/iOS-Native/NodeJS (WebDriver)/wdio.conf.js +2 -0
  63. package/resources/boilerplate/iOS-Native/Python/iOSNative-oss.py +31 -14
  64. package/resources/boilerplate/iOS-Native/Python/iOSNative.py +36 -15
  65. package/resources/boilerplate/iOS-Native/Robot Framework/iOSNative-oss.robot +28 -11
  66. package/resources/boilerplate/iOS-Native/java-JUnit5/gradle-oss +4 -1
  67. package/resources/boilerplate/iOS-Native/java-JUnit5/iOSNative-oss-po.java +45 -0
  68. package/resources/boilerplate/iOS-Native/java-JUnit5/iOSNative-oss.java +24 -13
  69. package/resources/boilerplate/iOS-Native/java-JUnit5/iOSNative.java +21 -11
  70. package/resources/boilerplate/iOS-Native/java-JUnit5/maven-oss +7 -1
  71. package/resources/boilerplate/iOS-Native/java-TestNG/gradle-oss +4 -1
  72. package/resources/boilerplate/iOS-Native/java-TestNG/iOSNative-oss-po.java +45 -0
  73. package/resources/boilerplate/iOS-Native/java-TestNG/iOSNative-oss.java +24 -13
  74. package/resources/boilerplate/iOS-Native/java-TestNG/iOSNative.java +21 -11
  75. package/resources/boilerplate/iOS-Native/java-TestNG/maven-oss +7 -1
  76. package/resources/boilerplate/shared/java-screens/AppScreen.java +27 -0
  77. package/resources/boilerplate/shared/java-screens/BaseScreen.java +40 -0
  78. package/resources/boilerplate/shared/java-screens/DashboardScreen.java +16 -0
  79. package/resources/boilerplate/shared/java-screens/LoginScreen.java +21 -0
  80. package/resources/boilerplate/shared/java-screens/PaymentScreen.java +32 -0
  81. package/resources/boilerplate/shared/node-screens/AppScreen.js +27 -0
  82. package/resources/boilerplate/shared/node-screens/DashboardScreen.js +13 -0
  83. package/resources/boilerplate/shared/node-screens/LoginScreen.js +18 -0
  84. package/resources/boilerplate/shared/node-screens/PaymentScreen.js +28 -0
  85. package/resources/boilerplate/shared/node-screens/PlaceholderScreen.js +21 -0
@@ -1,10 +1,15 @@
1
1
  import io.appium.java_client.ios.IOSDriver;
2
2
  import io.appium.java_client.ios.options.XCUITestOptions;
3
3
  import org.junit.jupiter.api.*;
4
+ import io.appium.java_client.AppiumBy;
4
5
  import org.openqa.selenium.By;
6
+ import org.openqa.selenium.WebElement;
7
+ import org.openqa.selenium.support.ui.ExpectedConditions;
8
+ import org.openqa.selenium.support.ui.WebDriverWait;
5
9
 
6
10
  import java.net.MalformedURLException;
7
- import java.net.URL;
11
+ import java.net.URI;
12
+ import java.time.Duration;
8
13
 
9
14
  public class LocaliOSTest {
10
15
 
@@ -18,23 +23,29 @@ public class LocaliOSTest {
18
23
  options.setCapability("digitalai:deviceQuery", "@os='ios' and @category='[Enter PHONE/TABLET here]'");
19
24
  options.setApp("cloud:com.experitest.ExperiBank");
20
25
  options.setBundleId("com.experitest.ExperiBank");
21
- driver = new IOSDriver(new URL("[Enter Instance here]/wd/hub"), options);
26
+ driver = new IOSDriver(URI.create("[Enter Instance here]/wd/hub").toURL(), options);
27
+ }
28
+
29
+ // Explicit wait: polls until the element is visible (20 s), then returns it. Used instead of an implicit wait —
30
+ // never mix the two (every miss then waits implicit + explicit, and the real timeout becomes unpredictable).
31
+ private WebElement find(By by) {
32
+ return new WebDriverWait(driver, Duration.ofSeconds(20)).until(ExpectedConditions.visibilityOfElementLocated(by));
22
33
  }
23
34
 
24
35
  @Test
25
36
  public void quickStartiOSNativeDemo() {
26
37
  // [BEGIN_DEMO_STEPS]
27
- driver.findElement(By.xpath("//*[@name='usernameTextField']")).sendKeys("company");
28
- driver.findElement(By.xpath("//*[@name='passwordTextField']")).sendKeys("company");
29
- driver.findElement(By.xpath("//*[@name='loginButton']")).click();
30
- driver.findElement(By.xpath("//*[@name='makePaymentButton']")).click();
31
- driver.findElement(By.xpath("//*[@name='phoneTextField']")).sendKeys("0501234567");
32
- driver.findElement(By.xpath("//*[@name='nameTextField']")).sendKeys("John Snow");
33
- driver.findElement(By.xpath("//*[@name='amountTextField']")).sendKeys("50");
34
- driver.findElement(By.xpath("//*[@name='countryButton']")).click();
35
- driver.findElement(By.xpath("//*[@name='Switzerland']")).click();
36
- driver.findElement(By.xpath("//*[@name='sendPaymentButton']")).click();
37
- driver.findElement(By.xpath("//*[@name='Yes']")).click();
38
+ find(AppiumBy.accessibilityId("usernameTextField")).sendKeys("company");
39
+ find(AppiumBy.accessibilityId("passwordTextField")).sendKeys("company");
40
+ find(AppiumBy.accessibilityId("loginButton")).click();
41
+ find(AppiumBy.accessibilityId("makePaymentButton")).click();
42
+ find(AppiumBy.accessibilityId("phoneTextField")).sendKeys("0501234567");
43
+ find(AppiumBy.accessibilityId("nameTextField")).sendKeys("John Snow");
44
+ find(AppiumBy.accessibilityId("amountTextField")).sendKeys("50");
45
+ find(AppiumBy.accessibilityId("countryButton")).click();
46
+ find(AppiumBy.accessibilityId("Switzerland")).click();
47
+ find(AppiumBy.accessibilityId("sendPaymentButton")).click();
48
+ find(AppiumBy.accessibilityId("Yes")).click();
38
49
  // [END_DEMO_STEPS]
39
50
  }
40
51
 
@@ -3,7 +3,11 @@ import io.appium.java_client.ios.IOSElement;
3
3
  import io.appium.java_client.remote.IOSMobileCapabilityType;
4
4
  import io.appium.java_client.remote.MobileCapabilityType;
5
5
  import org.junit.jupiter.api.*;
6
+ import io.appium.java_client.MobileBy;
6
7
  import org.openqa.selenium.By;
8
+ import org.openqa.selenium.WebElement;
9
+ import org.openqa.selenium.support.ui.ExpectedConditions;
10
+ import org.openqa.selenium.support.ui.WebDriverWait;
7
11
  import org.openqa.selenium.ScreenOrientation;
8
12
  import org.openqa.selenium.remote.DesiredCapabilities;
9
13
 
@@ -27,21 +31,27 @@ public class LocaliOSTest {
27
31
  driver = new IOSDriver<>(new URL("[Enter Instance here]/wd/hub"), dc);
28
32
  }
29
33
 
34
+ // Explicit wait (presence; 20 s) used instead of an implicit wait — never mix the two. Selenium 3 signature:
35
+ // java-client 7.x (required by the Appium Grid) pulls Selenium 3.141, whose WebDriverWait takes seconds as a long.
36
+ private WebElement find(By by) {
37
+ return new WebDriverWait(driver, 20).until(ExpectedConditions.presenceOfElementLocated(by));
38
+ }
39
+
30
40
  @Test
31
41
  public void quickStartiOSNativeDemo() {
32
42
  // [BEGIN_DEMO_STEPS]
33
43
  driver.rotate(ScreenOrientation.PORTRAIT);
34
- driver.findElement(By.xpath("//*[@name='usernameTextField']")).sendKeys("company");
35
- driver.findElement(By.xpath("//*[@name='passwordTextField']")).sendKeys("company");
36
- driver.findElement(By.xpath("//*[@name='loginButton']")).click();
37
- driver.findElement(By.xpath("//*[@name='makePaymentButton']")).click();
38
- driver.findElement(By.xpath("//*[@name='phoneTextField']")).sendKeys("0501234567");
39
- driver.findElement(By.xpath("//*[@name='nameTextField']")).sendKeys("John Snow");
40
- driver.findElement(By.xpath("//*[@name='amountTextField']")).sendKeys("50");
41
- driver.findElement(By.xpath("//*[@name='countryButton']")).click();
42
- driver.findElement(By.xpath("//*[@name='Switzerland']")).click();
43
- driver.findElement(By.xpath("//*[@name='sendPaymentButton']")).click();
44
- driver.findElement(By.xpath("//*[@name='Yes']")).click();
44
+ find(MobileBy.AccessibilityId("usernameTextField")).sendKeys("company");
45
+ find(MobileBy.AccessibilityId("passwordTextField")).sendKeys("company");
46
+ find(MobileBy.AccessibilityId("loginButton")).click();
47
+ find(MobileBy.AccessibilityId("makePaymentButton")).click();
48
+ find(MobileBy.AccessibilityId("phoneTextField")).sendKeys("0501234567");
49
+ find(MobileBy.AccessibilityId("nameTextField")).sendKeys("John Snow");
50
+ find(MobileBy.AccessibilityId("amountTextField")).sendKeys("50");
51
+ find(MobileBy.AccessibilityId("countryButton")).click();
52
+ find(MobileBy.AccessibilityId("Switzerland")).click();
53
+ find(MobileBy.AccessibilityId("sendPaymentButton")).click();
54
+ find(MobileBy.AccessibilityId("Yes")).click();
45
55
  // [END_DEMO_STEPS]
46
56
  }
47
57
 
@@ -33,10 +33,16 @@
33
33
  <version>5.10.2</version>
34
34
  <scope>test</scope>
35
35
  </dependency>
36
+ <!-- java-client 11 depends on selenium-api only ([4.50.0, 5.0)); selenium-java brings the drivers and support classes -->
36
37
  <dependency>
37
38
  <groupId>io.appium</groupId>
38
39
  <artifactId>java-client</artifactId>
39
- <version>8.6.0</version>
40
+ <version>11.0.0</version>
41
+ </dependency>
42
+ <dependency>
43
+ <groupId>org.seleniumhq.selenium</groupId>
44
+ <artifactId>selenium-java</artifactId>
45
+ <version>4.51.0</version>
40
46
  </dependency>
41
47
  </dependencies>
42
48
  </project>
@@ -9,5 +9,8 @@ test {
9
9
 
10
10
  dependencies {
11
11
  testImplementation group: 'org.testng', name: 'testng', version: '7.9.0'
12
- testImplementation group: 'io.appium', name: 'java-client', version: '8.6.0'
12
+ // java-client 11 depends on selenium-api only ([4.50.0, 5.0)) and Gradle resolves the LOWEST version in a range —
13
+ // selenium-java pins the drivers and support classes explicitly
14
+ testImplementation group: 'io.appium', name: 'java-client', version: '11.0.0'
15
+ testImplementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '4.51.0'
13
16
  }
@@ -0,0 +1,45 @@
1
+ import io.appium.java_client.ios.IOSDriver;
2
+ import io.appium.java_client.ios.options.XCUITestOptions;
3
+ import org.testng.annotations.*;
4
+
5
+ import java.net.MalformedURLException;
6
+ import java.net.URI;
7
+
8
+ /** Page-object layout: screens live next to this class (BaseScreen + one class per screen); the test reads as the flow. */
9
+ public class LocaliOSTest {
10
+
11
+ private IOSDriver driver;
12
+
13
+ @BeforeMethod
14
+ public void setUp() throws MalformedURLException {
15
+ XCUITestOptions options = new XCUITestOptions();
16
+ options.setCapability("digitalai:testName", "[Enter Test Name here]");
17
+ options.setCapability("digitalai:accessKey", "[Enter Your Access key here]");
18
+ options.setCapability("digitalai:deviceQuery", "@os='ios' and @category='[Enter PHONE/TABLET here]'");
19
+ options.setApp("cloud:com.experitest.ExperiBank");
20
+ options.setBundleId("com.experitest.ExperiBank");
21
+ driver = new IOSDriver(URI.create("[Enter Instance here]/wd/hub").toURL(), options);
22
+ }
23
+
24
+ @Test
25
+ public void quickStartiOSNativeDemo() {
26
+ // [BEGIN_DEMO_STEPS]
27
+ new LoginScreen(driver).login("company", "company")
28
+ .makePayment()
29
+ .fillPayment("0501234567", "John Snow", "50", "Switzerland")
30
+ .sendAndConfirm();
31
+ // [END_DEMO_STEPS]
32
+ }
33
+
34
+ @AfterMethod
35
+ public void tearDown() {
36
+ if (driver == null) return;
37
+ try {
38
+ System.out.println("Report URL: " + driver.getCapabilities().getCapability("digitalai:reportUrl"));
39
+ System.out.println("Report Test ID: " + driver.getCapabilities().getCapability("digitalai:reportTestId"));
40
+ } catch (Exception ignored) {}
41
+ try {
42
+ driver.quit();
43
+ } catch (Exception ignored) {}
44
+ }
45
+ }
@@ -1,10 +1,15 @@
1
1
  import io.appium.java_client.ios.IOSDriver;
2
2
  import io.appium.java_client.ios.options.XCUITestOptions;
3
3
  import org.testng.annotations.*;
4
+ import io.appium.java_client.AppiumBy;
4
5
  import org.openqa.selenium.By;
6
+ import org.openqa.selenium.WebElement;
7
+ import org.openqa.selenium.support.ui.ExpectedConditions;
8
+ import org.openqa.selenium.support.ui.WebDriverWait;
5
9
 
6
10
  import java.net.MalformedURLException;
7
- import java.net.URL;
11
+ import java.net.URI;
12
+ import java.time.Duration;
8
13
 
9
14
  public class LocaliOSTest {
10
15
 
@@ -18,23 +23,29 @@ public class LocaliOSTest {
18
23
  options.setCapability("digitalai:deviceQuery", "@os='ios' and @category='[Enter PHONE/TABLET here]'");
19
24
  options.setApp("cloud:com.experitest.ExperiBank");
20
25
  options.setBundleId("com.experitest.ExperiBank");
21
- driver = new IOSDriver(new URL("[Enter Instance here]/wd/hub"), options);
26
+ driver = new IOSDriver(URI.create("[Enter Instance here]/wd/hub").toURL(), options);
27
+ }
28
+
29
+ // Explicit wait: polls until the element is visible (20 s), then returns it. Used instead of an implicit wait —
30
+ // never mix the two (every miss then waits implicit + explicit, and the real timeout becomes unpredictable).
31
+ private WebElement find(By by) {
32
+ return new WebDriverWait(driver, Duration.ofSeconds(20)).until(ExpectedConditions.visibilityOfElementLocated(by));
22
33
  }
23
34
 
24
35
  @Test
25
36
  public void quickStartiOSNativeDemo() {
26
37
  // [BEGIN_DEMO_STEPS]
27
- driver.findElement(By.xpath("//*[@name='usernameTextField']")).sendKeys("company");
28
- driver.findElement(By.xpath("//*[@name='passwordTextField']")).sendKeys("company");
29
- driver.findElement(By.xpath("//*[@name='loginButton']")).click();
30
- driver.findElement(By.xpath("//*[@name='makePaymentButton']")).click();
31
- driver.findElement(By.xpath("//*[@name='phoneTextField']")).sendKeys("0501234567");
32
- driver.findElement(By.xpath("//*[@name='nameTextField']")).sendKeys("John Snow");
33
- driver.findElement(By.xpath("//*[@name='amountTextField']")).sendKeys("50");
34
- driver.findElement(By.xpath("//*[@name='countryButton']")).click();
35
- driver.findElement(By.xpath("//*[@name='Switzerland']")).click();
36
- driver.findElement(By.xpath("//*[@name='sendPaymentButton']")).click();
37
- driver.findElement(By.xpath("//*[@name='Yes']")).click();
38
+ find(AppiumBy.accessibilityId("usernameTextField")).sendKeys("company");
39
+ find(AppiumBy.accessibilityId("passwordTextField")).sendKeys("company");
40
+ find(AppiumBy.accessibilityId("loginButton")).click();
41
+ find(AppiumBy.accessibilityId("makePaymentButton")).click();
42
+ find(AppiumBy.accessibilityId("phoneTextField")).sendKeys("0501234567");
43
+ find(AppiumBy.accessibilityId("nameTextField")).sendKeys("John Snow");
44
+ find(AppiumBy.accessibilityId("amountTextField")).sendKeys("50");
45
+ find(AppiumBy.accessibilityId("countryButton")).click();
46
+ find(AppiumBy.accessibilityId("Switzerland")).click();
47
+ find(AppiumBy.accessibilityId("sendPaymentButton")).click();
48
+ find(AppiumBy.accessibilityId("Yes")).click();
38
49
  // [END_DEMO_STEPS]
39
50
  }
40
51
 
@@ -3,7 +3,11 @@ import io.appium.java_client.ios.IOSElement;
3
3
  import io.appium.java_client.remote.IOSMobileCapabilityType;
4
4
  import io.appium.java_client.remote.MobileCapabilityType;
5
5
  import org.testng.annotations.*;
6
+ import io.appium.java_client.MobileBy;
6
7
  import org.openqa.selenium.By;
8
+ import org.openqa.selenium.WebElement;
9
+ import org.openqa.selenium.support.ui.ExpectedConditions;
10
+ import org.openqa.selenium.support.ui.WebDriverWait;
7
11
  import org.openqa.selenium.ScreenOrientation;
8
12
  import org.openqa.selenium.remote.DesiredCapabilities;
9
13
 
@@ -27,21 +31,27 @@ public class LocaliOSTest {
27
31
  driver = new IOSDriver<>(new URL("[Enter Instance here]/wd/hub"), dc);
28
32
  }
29
33
 
34
+ // Explicit wait (presence; 20 s) used instead of an implicit wait — never mix the two. Selenium 3 signature:
35
+ // java-client 7.x (required by the Appium Grid) pulls Selenium 3.141, whose WebDriverWait takes seconds as a long.
36
+ private WebElement find(By by) {
37
+ return new WebDriverWait(driver, 20).until(ExpectedConditions.presenceOfElementLocated(by));
38
+ }
39
+
30
40
  @Test
31
41
  public void quickStartiOSNativeDemo() {
32
42
  // [BEGIN_DEMO_STEPS]
33
43
  driver.rotate(ScreenOrientation.PORTRAIT);
34
- driver.findElement(By.xpath("//*[@name='usernameTextField']")).sendKeys("company");
35
- driver.findElement(By.xpath("//*[@name='passwordTextField']")).sendKeys("company");
36
- driver.findElement(By.xpath("//*[@name='loginButton']")).click();
37
- driver.findElement(By.xpath("//*[@name='makePaymentButton']")).click();
38
- driver.findElement(By.xpath("//*[@name='phoneTextField']")).sendKeys("0501234567");
39
- driver.findElement(By.xpath("//*[@name='nameTextField']")).sendKeys("John Snow");
40
- driver.findElement(By.xpath("//*[@name='amountTextField']")).sendKeys("50");
41
- driver.findElement(By.xpath("//*[@name='countryButton']")).click();
42
- driver.findElement(By.xpath("//*[@name='Switzerland']")).click();
43
- driver.findElement(By.xpath("//*[@name='sendPaymentButton']")).click();
44
- driver.findElement(By.xpath("//*[@name='Yes']")).click();
44
+ find(MobileBy.AccessibilityId("usernameTextField")).sendKeys("company");
45
+ find(MobileBy.AccessibilityId("passwordTextField")).sendKeys("company");
46
+ find(MobileBy.AccessibilityId("loginButton")).click();
47
+ find(MobileBy.AccessibilityId("makePaymentButton")).click();
48
+ find(MobileBy.AccessibilityId("phoneTextField")).sendKeys("0501234567");
49
+ find(MobileBy.AccessibilityId("nameTextField")).sendKeys("John Snow");
50
+ find(MobileBy.AccessibilityId("amountTextField")).sendKeys("50");
51
+ find(MobileBy.AccessibilityId("countryButton")).click();
52
+ find(MobileBy.AccessibilityId("Switzerland")).click();
53
+ find(MobileBy.AccessibilityId("sendPaymentButton")).click();
54
+ find(MobileBy.AccessibilityId("Yes")).click();
45
55
  // [END_DEMO_STEPS]
46
56
  }
47
57
 
@@ -33,10 +33,16 @@
33
33
  <version>7.9.0</version>
34
34
  <scope>test</scope>
35
35
  </dependency>
36
+ <!-- java-client 11 depends on selenium-api only ([4.50.0, 5.0)); selenium-java brings the drivers and support classes -->
36
37
  <dependency>
37
38
  <groupId>io.appium</groupId>
38
39
  <artifactId>java-client</artifactId>
39
- <version>8.6.0</version>
40
+ <version>11.0.0</version>
41
+ </dependency>
42
+ <dependency>
43
+ <groupId>org.seleniumhq.selenium</groupId>
44
+ <artifactId>selenium-java</artifactId>
45
+ <version>4.51.0</version>
40
46
  </dependency>
41
47
  </dependencies>
42
48
  </project>
@@ -0,0 +1,27 @@
1
+ import io.appium.java_client.AppiumBy;
2
+ import io.appium.java_client.AppiumDriver;
3
+ import org.openqa.selenium.By;
4
+
5
+ /**
6
+ * ⛔ PLACEHOLDER SCREEN — the locators below are NOT real. Replace every <…> with a value captured from a live
7
+ * inspection (start_inspection_session -> get_element_tree / find_elements, or open_mobile_studio), rename the class to
8
+ * the screen it represents, and add one such class per screen. NEVER guess a resource-id or accessibility id.
9
+ */
10
+ public class AppScreen extends BaseScreen {
11
+ private final By primaryField = platform(By.id("<resource-id from get_element_tree>"), AppiumBy.accessibilityId("<accessibility id from get_element_tree>"));
12
+ private final By primaryButton = platform(By.id("<resource-id>"), AppiumBy.accessibilityId("<accessibility id>"));
13
+
14
+ public AppScreen(AppiumDriver driver) {
15
+ super(driver);
16
+ }
17
+
18
+ public AppScreen enterValue(String value) {
19
+ type(primaryField, value);
20
+ return this;
21
+ }
22
+
23
+ public AppScreen tapPrimaryButton() {
24
+ tap(primaryButton);
25
+ return this;
26
+ }
27
+ }
@@ -0,0 +1,40 @@
1
+ import io.appium.java_client.AppiumDriver;
2
+ import org.openqa.selenium.By;
3
+ import org.openqa.selenium.WebElement;
4
+ import org.openqa.selenium.support.ui.ExpectedConditions;
5
+ import org.openqa.selenium.support.ui.WebDriverWait;
6
+
7
+ import java.time.Duration;
8
+
9
+ /**
10
+ * One class per screen. Every interaction waits explicitly for its element (no implicit wait anywhere), and each
11
+ * locator is chosen per platform at runtime, so one screen class serves the Android and the iOS build of the app.
12
+ * Screens return the next screen, so a test reads as the user flow: new LoginScreen(driver).login(..).makePayment()..
13
+ */
14
+ public abstract class BaseScreen {
15
+ protected final AppiumDriver driver;
16
+ protected final boolean android;
17
+
18
+ protected BaseScreen(AppiumDriver driver) {
19
+ this.driver = driver;
20
+ this.android = "android".equalsIgnoreCase(String.valueOf(driver.getCapabilities().getPlatformName()));
21
+ }
22
+
23
+ /** Pick the locator for the platform this session runs on. */
24
+ protected By platform(By androidLocator, By iosLocator) {
25
+ return android ? androidLocator : iosLocator;
26
+ }
27
+
28
+ /** Explicit wait (20 s) until the element is visible, then return it. Never mix with an implicit wait. */
29
+ protected WebElement find(By by) {
30
+ return new WebDriverWait(driver, Duration.ofSeconds(20)).until(ExpectedConditions.visibilityOfElementLocated(by));
31
+ }
32
+
33
+ protected void tap(By by) {
34
+ find(by).click();
35
+ }
36
+
37
+ protected void type(By by, String text) {
38
+ find(by).sendKeys(text);
39
+ }
40
+ }
@@ -0,0 +1,16 @@
1
+ import io.appium.java_client.AppiumBy;
2
+ import io.appium.java_client.AppiumDriver;
3
+ import org.openqa.selenium.By;
4
+
5
+ public class DashboardScreen extends BaseScreen {
6
+ private final By makePaymentButton = platform(By.id("com.experitest.ExperiBank:id/makePaymentButton"), AppiumBy.accessibilityId("makePaymentButton"));
7
+
8
+ public DashboardScreen(AppiumDriver driver) {
9
+ super(driver);
10
+ }
11
+
12
+ public PaymentScreen makePayment() {
13
+ tap(makePaymentButton);
14
+ return new PaymentScreen(driver);
15
+ }
16
+ }
@@ -0,0 +1,21 @@
1
+ import io.appium.java_client.AppiumBy;
2
+ import io.appium.java_client.AppiumDriver;
3
+ import org.openqa.selenium.By;
4
+
5
+ public class LoginScreen extends BaseScreen {
6
+ // Android: resource-id. iOS: accessibility id (= the element's name — identifier, else label).
7
+ private final By username = platform(By.id("com.experitest.ExperiBank:id/usernameTextField"), AppiumBy.accessibilityId("usernameTextField"));
8
+ private final By password = platform(By.id("com.experitest.ExperiBank:id/passwordTextField"), AppiumBy.accessibilityId("passwordTextField"));
9
+ private final By loginButton = platform(By.id("com.experitest.ExperiBank:id/loginButton"), AppiumBy.accessibilityId("loginButton"));
10
+
11
+ public LoginScreen(AppiumDriver driver) {
12
+ super(driver);
13
+ }
14
+
15
+ public DashboardScreen login(String user, String pass) {
16
+ type(username, user);
17
+ type(password, pass);
18
+ tap(loginButton);
19
+ return new DashboardScreen(driver);
20
+ }
21
+ }
@@ -0,0 +1,32 @@
1
+ import io.appium.java_client.AppiumBy;
2
+ import io.appium.java_client.AppiumDriver;
3
+ import org.openqa.selenium.By;
4
+
5
+ public class PaymentScreen extends BaseScreen {
6
+ private final By phone = platform(By.id("com.experitest.ExperiBank:id/phoneTextField"), AppiumBy.accessibilityId("phoneTextField"));
7
+ private final By name = platform(By.id("com.experitest.ExperiBank:id/nameTextField"), AppiumBy.accessibilityId("nameTextField"));
8
+ private final By amount = platform(By.id("com.experitest.ExperiBank:id/amountTextField"), AppiumBy.accessibilityId("amountTextField"));
9
+ private final By countryButton = platform(By.id("com.experitest.ExperiBank:id/countryButton"), AppiumBy.accessibilityId("countryButton"));
10
+ private final By sendPaymentButton = platform(By.id("com.experitest.ExperiBank:id/sendPaymentButton"), AppiumBy.accessibilityId("sendPaymentButton"));
11
+ // The confirmation is a system dialog on Android (android:id/button1) and a named button on iOS.
12
+ private final By confirmYes = platform(By.id("android:id/button1"), AppiumBy.accessibilityId("Yes"));
13
+
14
+ public PaymentScreen(AppiumDriver driver) {
15
+ super(driver);
16
+ }
17
+
18
+ public PaymentScreen fillPayment(String phoneNumber, String payee, String amountValue, String country) {
19
+ type(phone, phoneNumber);
20
+ type(name, payee);
21
+ type(amount, amountValue);
22
+ tap(countryButton);
23
+ // Country list entry: visible text on Android, accessibility id (= label) on iOS.
24
+ tap(platform(By.xpath("//*[@text='" + country + "']"), AppiumBy.accessibilityId(country)));
25
+ return this;
26
+ }
27
+
28
+ public void sendAndConfirm() {
29
+ tap(sendPaymentButton);
30
+ tap(confirmYes);
31
+ }
32
+ }
@@ -0,0 +1,27 @@
1
+ // Base screen: every interaction waits explicitly (waitforTimeout in wdio.conf.js); locators are chosen per platform at
2
+ // runtime so one screen class serves the Android and the iOS build. Screens return the next screen.
3
+ class AppScreen {
4
+ constructor() {
5
+ this.isAndroid = browser.isAndroid;
6
+ }
7
+
8
+ platform(androidSelector, iosSelector) {
9
+ return this.isAndroid ? androidSelector : iosSelector;
10
+ }
11
+
12
+ async find(selector) {
13
+ const el = await $(selector);
14
+ await el.waitForDisplayed();
15
+ return el;
16
+ }
17
+
18
+ async tap(selector) {
19
+ await (await this.find(selector)).click();
20
+ }
21
+
22
+ async type(selector, text) {
23
+ await (await this.find(selector)).setValue(text);
24
+ }
25
+ }
26
+
27
+ module.exports = AppScreen;
@@ -0,0 +1,13 @@
1
+ const AppScreen = require('./AppScreen');
2
+ const PaymentScreen = require('./PaymentScreen');
3
+
4
+ class DashboardScreen extends AppScreen {
5
+ get makePaymentButton() { return this.platform('id=com.experitest.ExperiBank:id/makePaymentButton', '~makePaymentButton'); }
6
+
7
+ async makePayment() {
8
+ await this.tap(this.makePaymentButton);
9
+ return new PaymentScreen();
10
+ }
11
+ }
12
+
13
+ module.exports = DashboardScreen;
@@ -0,0 +1,18 @@
1
+ const AppScreen = require('./AppScreen');
2
+ const DashboardScreen = require('./DashboardScreen');
3
+
4
+ class LoginScreen extends AppScreen {
5
+ // Android: resource-id ("id=…"). iOS: accessibility id ("~…" = the element's name — identifier, else label).
6
+ get username() { return this.platform('id=com.experitest.ExperiBank:id/usernameTextField', '~usernameTextField'); }
7
+ get password() { return this.platform('id=com.experitest.ExperiBank:id/passwordTextField', '~passwordTextField'); }
8
+ get loginButton() { return this.platform('id=com.experitest.ExperiBank:id/loginButton', '~loginButton'); }
9
+
10
+ async login(user, pass) {
11
+ await this.type(this.username, user);
12
+ await this.type(this.password, pass);
13
+ await this.tap(this.loginButton);
14
+ return new DashboardScreen();
15
+ }
16
+ }
17
+
18
+ module.exports = LoginScreen;
@@ -0,0 +1,28 @@
1
+ const AppScreen = require('./AppScreen');
2
+
3
+ class PaymentScreen extends AppScreen {
4
+ get phone() { return this.platform('id=com.experitest.ExperiBank:id/phoneTextField', '~phoneTextField'); }
5
+ get name() { return this.platform('id=com.experitest.ExperiBank:id/nameTextField', '~nameTextField'); }
6
+ get amount() { return this.platform('id=com.experitest.ExperiBank:id/amountTextField', '~amountTextField'); }
7
+ get countryButton() { return this.platform('id=com.experitest.ExperiBank:id/countryButton', '~countryButton'); }
8
+ get sendPaymentButton() { return this.platform('id=com.experitest.ExperiBank:id/sendPaymentButton', '~sendPaymentButton'); }
9
+ // The confirmation is a system dialog on Android and a named button on iOS.
10
+ get confirmYes() { return this.platform('id=android:id/button1', '~Yes'); }
11
+
12
+ async fillPayment(phoneNumber, payee, amountValue, country) {
13
+ await this.type(this.phone, phoneNumber);
14
+ await this.type(this.name, payee);
15
+ await this.type(this.amount, amountValue);
16
+ await this.tap(this.countryButton);
17
+ // Country list entry: visible text on Android, accessibility id (= label) on iOS.
18
+ await this.tap(this.platform(`//*[@text="${country}"]`, `~${country}`));
19
+ return this;
20
+ }
21
+
22
+ async sendAndConfirm() {
23
+ await this.tap(this.sendPaymentButton);
24
+ await this.tap(this.confirmYes);
25
+ }
26
+ }
27
+
28
+ module.exports = PaymentScreen;
@@ -0,0 +1,21 @@
1
+ const AppScreen = require('./AppScreen');
2
+
3
+ // ⛔ PLACEHOLDER SCREEN — the selectors below are NOT real. Replace every <…> with a value captured from a live
4
+ // inspection (start_inspection_session -> get_element_tree / find_elements, or open_mobile_studio), rename the class to
5
+ // the screen it represents, and add one such class per screen. NEVER guess a resource-id or accessibility id.
6
+ class PlaceholderScreen extends AppScreen {
7
+ get primaryField() { return this.platform('id=<resource-id from get_element_tree>', '~<accessibility id from get_element_tree>'); }
8
+ get primaryButton() { return this.platform('id=<resource-id>', '~<accessibility id>'); }
9
+
10
+ async enterValue(value) {
11
+ await this.type(this.primaryField, value);
12
+ return this;
13
+ }
14
+
15
+ async tapPrimaryButton() {
16
+ await this.tap(this.primaryButton);
17
+ return this;
18
+ }
19
+ }
20
+
21
+ module.exports = PlaceholderScreen;