digital-ai-testing-mcp 2.1.1 → 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 (72) hide show
  1. package/README.md +18 -13
  2. package/dist/api/webdriver.d.ts +61 -3
  3. package/dist/api/webdriver.d.ts.map +1 -1
  4. package/dist/api/webdriver.js +659 -33
  5. package/dist/api/webdriver.js.map +1 -1
  6. package/dist/index.js +1 -0
  7. package/dist/index.js.map +1 -1
  8. package/dist/tools/boilerplate-tools.d.ts +1 -1
  9. package/dist/tools/boilerplate-tools.d.ts.map +1 -1
  10. package/dist/tools/boilerplate-tools.js +155 -52
  11. package/dist/tools/boilerplate-tools.js.map +1 -1
  12. package/dist/tools/inspection-tools.d.ts.map +1 -1
  13. package/dist/tools/inspection-tools.js +217 -23
  14. package/dist/tools/inspection-tools.js.map +1 -1
  15. package/dist/tools/meta-tools.d.ts +1 -1
  16. package/dist/tools/meta-tools.d.ts.map +1 -1
  17. package/dist/tools/meta-tools.js +2 -1
  18. package/dist/tools/meta-tools.js.map +1 -1
  19. package/dist/tools/performance-tools.d.ts.map +1 -1
  20. package/dist/tools/performance-tools.js +6 -1
  21. package/dist/tools/performance-tools.js.map +1 -1
  22. package/dist/types/digital-ai.d.ts +8 -0
  23. package/dist/types/digital-ai.d.ts.map +1 -1
  24. package/dist/utils/test-orchestrator.d.ts +2 -0
  25. package/dist/utils/test-orchestrator.d.ts.map +1 -1
  26. package/dist/utils/test-orchestrator.js +2 -0
  27. package/dist/utils/test-orchestrator.js.map +1 -1
  28. package/package.json +3 -1
  29. package/resources/boilerplate/Android-Native/Java JUnit5/AndroidNative-oss-po.java +48 -0
  30. package/resources/boilerplate/Android-Native/Java JUnit5/AndroidNative-oss.java +23 -13
  31. package/resources/boilerplate/Android-Native/Java JUnit5/AndroidNative.java +19 -10
  32. package/resources/boilerplate/Android-Native/Java JUnit5/gradle-oss +4 -1
  33. package/resources/boilerplate/Android-Native/Java JUnit5/maven-oss +7 -1
  34. package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/AndroidNative-po.js +13 -0
  35. package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/AndroidNative.js +17 -11
  36. package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/wdio-oss.conf.js +7 -2
  37. package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/wdio.conf.js +10 -4
  38. package/resources/boilerplate/Android-Native/Python/AndroidNative-oss.py +30 -14
  39. package/resources/boilerplate/Android-Native/Python/AndroidNative.py +21 -5
  40. package/resources/boilerplate/Android-Native/Robot Framework/AndroidNative-oss.robot +28 -11
  41. package/resources/boilerplate/Android-Native/java TestNG/AndroidNative-oss-po.java +48 -0
  42. package/resources/boilerplate/Android-Native/java TestNG/AndroidNative-oss.java +23 -13
  43. package/resources/boilerplate/Android-Native/java TestNG/AndroidNative.java +19 -10
  44. package/resources/boilerplate/Android-Native/java TestNG/gradle-oss +4 -1
  45. package/resources/boilerplate/Android-Native/java TestNG/maven-oss +7 -1
  46. package/resources/boilerplate/iOS-Native/NodeJS (WebDriver)/iOSNative-po.js +13 -0
  47. package/resources/boilerplate/iOS-Native/NodeJS (WebDriver)/iOSNative.js +17 -11
  48. package/resources/boilerplate/iOS-Native/NodeJS (WebDriver)/wdio-oss.conf.js +4 -1
  49. package/resources/boilerplate/iOS-Native/NodeJS (WebDriver)/wdio.conf.js +2 -0
  50. package/resources/boilerplate/iOS-Native/Python/iOSNative-oss.py +31 -14
  51. package/resources/boilerplate/iOS-Native/Python/iOSNative.py +36 -15
  52. package/resources/boilerplate/iOS-Native/Robot Framework/iOSNative-oss.robot +28 -11
  53. package/resources/boilerplate/iOS-Native/java-JUnit5/gradle-oss +4 -1
  54. package/resources/boilerplate/iOS-Native/java-JUnit5/iOSNative-oss-po.java +45 -0
  55. package/resources/boilerplate/iOS-Native/java-JUnit5/iOSNative-oss.java +24 -13
  56. package/resources/boilerplate/iOS-Native/java-JUnit5/iOSNative.java +21 -11
  57. package/resources/boilerplate/iOS-Native/java-JUnit5/maven-oss +7 -1
  58. package/resources/boilerplate/iOS-Native/java-TestNG/gradle-oss +4 -1
  59. package/resources/boilerplate/iOS-Native/java-TestNG/iOSNative-oss-po.java +45 -0
  60. package/resources/boilerplate/iOS-Native/java-TestNG/iOSNative-oss.java +24 -13
  61. package/resources/boilerplate/iOS-Native/java-TestNG/iOSNative.java +21 -11
  62. package/resources/boilerplate/iOS-Native/java-TestNG/maven-oss +7 -1
  63. package/resources/boilerplate/shared/java-screens/AppScreen.java +27 -0
  64. package/resources/boilerplate/shared/java-screens/BaseScreen.java +40 -0
  65. package/resources/boilerplate/shared/java-screens/DashboardScreen.java +16 -0
  66. package/resources/boilerplate/shared/java-screens/LoginScreen.java +21 -0
  67. package/resources/boilerplate/shared/java-screens/PaymentScreen.java +32 -0
  68. package/resources/boilerplate/shared/node-screens/AppScreen.js +27 -0
  69. package/resources/boilerplate/shared/node-screens/DashboardScreen.js +13 -0
  70. package/resources/boilerplate/shared/node-screens/LoginScreen.js +18 -0
  71. package/resources/boilerplate/shared/node-screens/PaymentScreen.js +28 -0
  72. package/resources/boilerplate/shared/node-screens/PlaceholderScreen.js +21 -0
@@ -25,21 +25,38 @@ ${TEST_NAME} [Enter Test Name here]
25
25
  Quick Start Android Native Demo
26
26
  Start Steps Group Test steps
27
27
  # [BEGIN_DEMO_STEPS]
28
- Input Text id=com.experitest.ExperiBank:id/usernameTextField company
29
- Input Text id=com.experitest.ExperiBank:id/passwordTextField company
30
- Click Element id=com.experitest.ExperiBank:id/loginButton
31
- Click Element id=com.experitest.ExperiBank:id/makePaymentButton
32
- Input Text id=com.experitest.ExperiBank:id/phoneTextField 0501234567
33
- Input Text id=com.experitest.ExperiBank:id/nameTextField John Snow
34
- Input Text id=com.experitest.ExperiBank:id/amountTextField 50
35
- Click Element xpath=//*[@resource-id='com.experitest.ExperiBank:id/countryButton']
36
- Click Element xpath=//*[@text='Switzerland']
37
- Click Element id=com.experitest.ExperiBank:id/sendPaymentButton
38
- Click Element id=android:id/button1
28
+ Wait And Input id=com.experitest.ExperiBank:id/usernameTextField company
29
+ Wait And Input id=com.experitest.ExperiBank:id/passwordTextField company
30
+ Wait And Click id=com.experitest.ExperiBank:id/loginButton
31
+ Wait And Click id=com.experitest.ExperiBank:id/makePaymentButton
32
+ Wait And Input id=com.experitest.ExperiBank:id/phoneTextField 0501234567
33
+ Wait And Input id=com.experitest.ExperiBank:id/nameTextField John Snow
34
+ Wait And Input id=com.experitest.ExperiBank:id/amountTextField 50
35
+ Wait And Click id=com.experitest.ExperiBank:id/countryButton
36
+ Wait And Click xpath=//*[@text='Switzerland']
37
+ Wait And Click id=com.experitest.ExperiBank:id/sendPaymentButton
38
+ Wait And Click id=android:id/button1
39
39
  # [END_DEMO_STEPS]
40
40
  Stop Steps Group
41
41
 
42
42
  *** Keywords ***
43
+ Wait And Click
44
+ [Arguments] ${locator}
45
+ # Explicit wait before every interaction — AppiumLibrary's Click Element / Input Text do not wait on their own.
46
+ Wait Until Element Is Visible ${locator} 20s
47
+ Click Element ${locator}
48
+
49
+ Wait And Input
50
+ [Arguments] ${locator} ${text}
51
+ Wait Until Element Is Visible ${locator} 20s
52
+ Input Text ${locator} ${text}
53
+
54
+ # More AppiumLibrary keywords that fit a device farm (all built in, no extra library):
55
+ # Expect Text <text> visible timeout=20s polling assertion (also Expect Element <locator> visible)
56
+ # Scroll Element Into View <locator> reach content below the fold
57
+ # ${contexts}= Get Contexts / Switch To Context WEBVIEW_... / Switch To Context NATIVE_APP (hybrid screens)
58
+ # Background Application 5 lifecycle check
59
+
43
60
  Open Cloud Session
44
61
  Open Application ${REMOTE_URL} &{CAPABILITIES}
45
62
 
@@ -0,0 +1,48 @@
1
+ import io.appium.java_client.android.AndroidDriver;
2
+ import io.appium.java_client.android.options.UiAutomator2Options;
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 LocalAndroidTest {
10
+
11
+ private AndroidDriver driver;
12
+
13
+ @BeforeMethod
14
+ public void setUp() throws MalformedURLException {
15
+ UiAutomator2Options options = new UiAutomator2Options();
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='android' and @category='[Enter PHONE/TABLET here]'");
19
+ options.setApp("cloud:com.experitest.ExperiBank/.LoginActivity");
20
+ options.setAppPackage("com.experitest.ExperiBank");
21
+ options.setAppActivity(".LoginActivity");
22
+ options.setCapability("autoDismissAlerts", true);
23
+ options.setCapability("autoGrantPermissions", true);
24
+ driver = new AndroidDriver(URI.create("[Enter Instance here]/wd/hub").toURL(), options);
25
+ }
26
+
27
+ @Test
28
+ public void quickStartAndroidNativeDemo() {
29
+ // [BEGIN_DEMO_STEPS]
30
+ new LoginScreen(driver).login("company", "company")
31
+ .makePayment()
32
+ .fillPayment("0501234567", "John Snow", "50", "Switzerland")
33
+ .sendAndConfirm();
34
+ // [END_DEMO_STEPS]
35
+ }
36
+
37
+ @AfterMethod
38
+ public void tearDown() {
39
+ if (driver == null) return;
40
+ try {
41
+ System.out.println("Report URL: " + driver.getCapabilities().getCapability("digitalai:reportUrl"));
42
+ System.out.println("Report Test ID: " + driver.getCapabilities().getCapability("digitalai:reportTestId"));
43
+ } catch (Exception ignored) {}
44
+ try {
45
+ driver.quit();
46
+ } catch (Exception ignored) {}
47
+ }
48
+ }
@@ -2,9 +2,13 @@ import io.appium.java_client.android.AndroidDriver;
2
2
  import io.appium.java_client.android.options.UiAutomator2Options;
3
3
  import org.testng.annotations.*;
4
4
  import org.openqa.selenium.By;
5
+ import org.openqa.selenium.WebElement;
6
+ import org.openqa.selenium.support.ui.ExpectedConditions;
7
+ import org.openqa.selenium.support.ui.WebDriverWait;
5
8
 
6
9
  import java.net.MalformedURLException;
7
- import java.net.URL;
10
+ import java.net.URI;
11
+ import java.time.Duration;
8
12
 
9
13
  public class LocalAndroidTest {
10
14
 
@@ -24,23 +28,29 @@ public class LocalAndroidTest {
24
28
  // System-level overlays (charging dialog, USB prompt) are NOT caught by autoDismissAlerts.
25
29
  // If they block tests, call after driver init:
26
30
  // driver.executeScript("mobile: shell", Map.of("command","am","args",List.of("broadcast","-a","android.intent.action.CLOSE_SYSTEM_DIALOGS")));
27
- driver = new AndroidDriver(new URL("[Enter Instance here]/wd/hub"), options);
31
+ driver = new AndroidDriver(URI.create("[Enter Instance here]/wd/hub").toURL(), options);
32
+ }
33
+
34
+ // Explicit wait: polls until the element is visible (20 s), then returns it. Used instead of an implicit wait —
35
+ // never mix the two (every miss then waits implicit + explicit, and the real timeout becomes unpredictable).
36
+ private WebElement find(By by) {
37
+ return new WebDriverWait(driver, Duration.ofSeconds(20)).until(ExpectedConditions.visibilityOfElementLocated(by));
28
38
  }
29
39
 
30
40
  @Test
31
41
  public void quickStartAndroidNativeDemo() {
32
42
  // [BEGIN_DEMO_STEPS]
33
- driver.findElement(By.id("com.experitest.ExperiBank:id/usernameTextField")).sendKeys("company");
34
- driver.findElement(By.id("com.experitest.ExperiBank:id/passwordTextField")).sendKeys("company");
35
- driver.findElement(By.id("com.experitest.ExperiBank:id/loginButton")).click();
36
- driver.findElement(By.id("com.experitest.ExperiBank:id/makePaymentButton")).click();
37
- driver.findElement(By.id("com.experitest.ExperiBank:id/phoneTextField")).sendKeys("0501234567");
38
- driver.findElement(By.id("com.experitest.ExperiBank:id/nameTextField")).sendKeys("John Snow");
39
- driver.findElement(By.id("com.experitest.ExperiBank:id/amountTextField")).sendKeys("50");
40
- driver.findElement(By.xpath("//*[@resource-id='com.experitest.ExperiBank:id/countryButton']")).click();
41
- driver.findElement(By.xpath("//*[@text='Switzerland']")).click();
42
- driver.findElement(By.id("com.experitest.ExperiBank:id/sendPaymentButton")).click();
43
- driver.findElement(By.id("android:id/button1")).click();
43
+ find(By.id("com.experitest.ExperiBank:id/usernameTextField")).sendKeys("company");
44
+ find(By.id("com.experitest.ExperiBank:id/passwordTextField")).sendKeys("company");
45
+ find(By.id("com.experitest.ExperiBank:id/loginButton")).click();
46
+ find(By.id("com.experitest.ExperiBank:id/makePaymentButton")).click();
47
+ find(By.id("com.experitest.ExperiBank:id/phoneTextField")).sendKeys("0501234567");
48
+ find(By.id("com.experitest.ExperiBank:id/nameTextField")).sendKeys("John Snow");
49
+ find(By.id("com.experitest.ExperiBank:id/amountTextField")).sendKeys("50");
50
+ find(By.id("com.experitest.ExperiBank:id/countryButton")).click();
51
+ find(By.xpath("//*[@text='Switzerland']")).click();
52
+ find(By.id("com.experitest.ExperiBank:id/sendPaymentButton")).click();
53
+ find(By.id("android:id/button1")).click();
44
54
  // [END_DEMO_STEPS]
45
55
  }
46
56
 
@@ -4,6 +4,9 @@ import io.appium.java_client.remote.AndroidMobileCapabilityType;
4
4
  import io.appium.java_client.remote.MobileCapabilityType;
5
5
  import org.testng.annotations.*;
6
6
  import org.openqa.selenium.By;
7
+ import org.openqa.selenium.WebElement;
8
+ import org.openqa.selenium.support.ui.ExpectedConditions;
9
+ import org.openqa.selenium.support.ui.WebDriverWait;
7
10
  import org.openqa.selenium.ScreenOrientation;
8
11
  import org.openqa.selenium.remote.DesiredCapabilities;
9
12
 
@@ -36,20 +39,26 @@ public class LocalAndroidTest {
36
39
  driver = new AndroidDriver<>(new URL("[Enter Instance here]/wd/hub"), dc);
37
40
  }
38
41
 
42
+ // Explicit wait (presence; 20 s) used instead of an implicit wait — never mix the two. Selenium 3 signature:
43
+ // java-client 7.x (required by the Appium Grid) pulls Selenium 3.141, whose WebDriverWait takes seconds as a long.
44
+ private WebElement find(By by) {
45
+ return new WebDriverWait(driver, 20).until(ExpectedConditions.presenceOfElementLocated(by));
46
+ }
47
+
39
48
  @Test
40
49
  public void quickStartAndroidNativeDemo() {
41
50
  // [BEGIN_DEMO_STEPS]
42
51
  driver.rotate(ScreenOrientation.PORTRAIT);
43
- driver.findElement(By.id("com.experitest.ExperiBank:id/usernameTextField")).sendKeys("company");
44
- driver.findElement(By.id("com.experitest.ExperiBank:id/passwordTextField")).sendKeys("company");
45
- driver.findElement(By.id("com.experitest.ExperiBank:id/loginButton")).click();
46
- driver.findElement(By.id("com.experitest.ExperiBank:id/makePaymentButton")).click();
47
- driver.findElement(By.id("com.experitest.ExperiBank:id/phoneTextField")).sendKeys("0501234567");
48
- driver.findElement(By.id("com.experitest.ExperiBank:id/nameTextField")).sendKeys("John Snow");
49
- driver.findElement(By.id("com.experitest.ExperiBank:id/amountTextField")).sendKeys("50");
50
- driver.findElement(By.id("com.experitest.ExperiBank:id/countryTextField")).sendKeys("'Switzerland'");
51
- driver.findElement(By.id("com.experitest.ExperiBank:id/sendPaymentButton")).click();
52
- driver.findElement(By.id("android:id/button1")).click();
52
+ find(By.id("com.experitest.ExperiBank:id/usernameTextField")).sendKeys("company");
53
+ find(By.id("com.experitest.ExperiBank:id/passwordTextField")).sendKeys("company");
54
+ find(By.id("com.experitest.ExperiBank:id/loginButton")).click();
55
+ find(By.id("com.experitest.ExperiBank:id/makePaymentButton")).click();
56
+ find(By.id("com.experitest.ExperiBank:id/phoneTextField")).sendKeys("0501234567");
57
+ find(By.id("com.experitest.ExperiBank:id/nameTextField")).sendKeys("John Snow");
58
+ find(By.id("com.experitest.ExperiBank:id/amountTextField")).sendKeys("50");
59
+ find(By.id("com.experitest.ExperiBank:id/countryTextField")).sendKeys("'Switzerland'");
60
+ find(By.id("com.experitest.ExperiBank:id/sendPaymentButton")).click();
61
+ find(By.id("android:id/button1")).click();
53
62
  // [END_DEMO_STEPS]
54
63
  }
55
64
 
@@ -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
  }
@@ -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,13 @@
1
+ const LoginScreen = require('../screenobjects/LoginScreen');
2
+
3
+ describe('LocaliOSTest', () => {
4
+ it('[testNameHere]', myTest)
5
+ })
6
+ async function myTest() {
7
+ // [BEGIN_DEMO_STEPS]
8
+ const dashboard = await new LoginScreen().login('company', 'company');
9
+ const payment = await dashboard.makePayment();
10
+ await payment.fillPayment('0541234567', 'Jon Snow', '50', 'Switzerland');
11
+ await payment.sendAndConfirm();
12
+ // [END_DEMO_STEPS]
13
+ }
@@ -1,29 +1,35 @@
1
1
  describe('LocaliOSTest', () => {
2
2
  it('[testNameHere]', myTest)
3
3
  })
4
+ // Explicit wait: resolve the element and wait until it is displayed (waitforTimeout in wdio.conf.js) before acting.
5
+ async function find(selector) {
6
+ const el = await $(selector);
7
+ await el.waitForDisplayed();
8
+ return el;
9
+ }
4
10
  async function myTest() {
5
11
  // [BEGIN_DEMO_STEPS]
6
- const username = await $('//*[@name="usernameTextField"]');
12
+ const username = await find('~usernameTextField');
7
13
  await username.setValue('company');
8
- const password = await $('//*[@name="passwordTextField"]');
14
+ const password = await find('~passwordTextField');
9
15
  await password.setValue('company');
10
- const loginButton = await $('//*[@name="loginButton"]');
16
+ const loginButton = await find('~loginButton');
11
17
  await loginButton.click();
12
- const makePaymentButton = await $('//*[@name="makePaymentButton"]');
18
+ const makePaymentButton = await find('~makePaymentButton');
13
19
  await makePaymentButton.click();
14
- const phoneNumber = await $("//*[@name='phoneTextField']");
20
+ const phoneNumber = await find('~phoneTextField');
15
21
  await phoneNumber.setValue('0541234567');
16
- const name = await $("//*[@name='nameTextField']");
22
+ const name = await find('~nameTextField');
17
23
  await name.setValue('Jon Snow');
18
- const amount = await $("//*[@name='amountTextField']");
24
+ const amount = await find('~amountTextField');
19
25
  await amount.setValue('50');
20
- const countryButton = await $("//*[@name='countryButton']");
26
+ const countryButton = await find('~countryButton');
21
27
  await countryButton.click();
22
- const country = await $("//*[@name='Switzerland']");
28
+ const country = await find('~Switzerland');
23
29
  await country.click();
24
- const sendPaymentButton = await $("//*[@name='sendPaymentButton']");
30
+ const sendPaymentButton = await find('~sendPaymentButton');
25
31
  await sendPaymentButton.click();
26
- const yesButton = await $("//*[@name='Yes']");
32
+ const yesButton = await find('~Yes');
27
33
  await yesButton.click();
28
34
  // [END_DEMO_STEPS]
29
35
  }
@@ -6,6 +6,8 @@ exports.config = {
6
6
  path: '/wd/hub',
7
7
  specs: ['./test/specs/iOSNative.js'],
8
8
  exclude: [],
9
+ // Parallel runs: each spec file gets its own device session — raise this to the number of workers you want
10
+ // (check the project's maxDevelopmentLicense and free matching devices first) and split tests across spec files.
9
11
  maxInstances: 1,
10
12
  capabilities: [{
11
13
  platformName: 'iOS',
@@ -17,7 +19,8 @@ exports.config = {
17
19
  }],
18
20
  logLevel: 'info',
19
21
  bail: 0,
20
- waitforTimeout: 10000,
22
+ // Native apps on a device farm need longer than the wdio default: the first $() races app install + launch.
23
+ waitforTimeout: 45000,
21
24
  connectionRetryTimeout: 120000,
22
25
  connectionRetryCount: 3,
23
26
  framework: 'mocha',
@@ -8,6 +8,8 @@ exports.config = {
8
8
  path: '/wd/hub',
9
9
  specs: ['./test/specs/iOSNative.js'],
10
10
  exclude: [],
11
+ // Parallel runs: each spec file gets its own device session — raise this to the number of workers you want
12
+ // (check the project's maxDevelopmentLicense and free matching devices first) and split tests across spec files.
11
13
  maxInstances: 1,
12
14
  capabilities: [{
13
15
  platformName: 'IOS',
@@ -2,6 +2,9 @@ import unittest
2
2
  from appium import webdriver
3
3
  from appium.options.common.base import AppiumOptions
4
4
  from selenium.webdriver.common.by import By
5
+ from appium.webdriver.common.appiumby import AppiumBy
6
+ from selenium.webdriver.support.ui import WebDriverWait
7
+ from selenium.webdriver.support import expected_conditions as EC
5
8
 
6
9
 
7
10
  class LocalIosTest(unittest.TestCase):
@@ -18,26 +21,40 @@ class LocalIosTest(unittest.TestCase):
18
21
  options.set_capability('platformName', 'ios')
19
22
  options.set_capability('digitalai:deviceQuery', "@os='ios' and @category='[Enter PHONE/TABLET here]'")
20
23
  self.driver = webdriver.Remote("[Enter Instance here]/wd/hub", options=options)
21
- self.driver.implicitly_wait(10)
24
+
25
+ def find(self, by, locator, timeout=20):
26
+ # Explicit wait: polls until the element is visible, then returns it. Used instead of an implicit wait — never
27
+ # mix the two (every miss then waits implicit + explicit, and the real timeout becomes unpredictable).
28
+ return WebDriverWait(self.driver, timeout).until(EC.visibility_of_element_located((by, locator)))
22
29
 
23
30
  def testQuickStartIosNativeDemo(self):
24
31
  # [BEGIN_DEMO_STEPS]
25
- self.driver.find_element(By.XPATH, "//*[@name='usernameTextField']").send_keys('company')
26
- self.driver.find_element(By.XPATH, "//*[@name='passwordTextField']").send_keys('company')
27
- self.driver.find_element(By.XPATH, "//*[@name='loginButton']").click()
28
- self.driver.find_element(By.XPATH, "//*[@name='makePaymentButton']").click()
29
- self.driver.find_element(By.XPATH, "//*[@name='phoneTextField']").send_keys('1234567')
30
- self.driver.find_element(By.XPATH, "//*[@name='nameTextField']").send_keys('Jon Snow')
31
- self.driver.find_element(By.XPATH, "//*[@name='amountTextField']").send_keys('50')
32
- self.driver.find_element(By.XPATH, "//*[@name='countryButton']").click()
33
- self.driver.find_element(By.XPATH, "//*[@name='Switzerland']").click()
34
- self.driver.find_element(By.XPATH, "//*[@name='sendPaymentButton']").click()
35
- self.driver.find_element(By.XPATH, "//*[@name='Yes']").click()
32
+ self.find(AppiumBy.ACCESSIBILITY_ID, 'usernameTextField').send_keys('company')
33
+ self.find(AppiumBy.ACCESSIBILITY_ID, 'passwordTextField').send_keys('company')
34
+ self.find(AppiumBy.ACCESSIBILITY_ID, 'loginButton').click()
35
+ self.find(AppiumBy.ACCESSIBILITY_ID, 'makePaymentButton').click()
36
+ self.find(AppiumBy.ACCESSIBILITY_ID, 'phoneTextField').send_keys('1234567')
37
+ self.find(AppiumBy.ACCESSIBILITY_ID, 'nameTextField').send_keys('Jon Snow')
38
+ self.find(AppiumBy.ACCESSIBILITY_ID, 'amountTextField').send_keys('50')
39
+ self.find(AppiumBy.ACCESSIBILITY_ID, 'countryButton').click()
40
+ self.find(AppiumBy.ACCESSIBILITY_ID, 'Switzerland').click()
41
+ self.find(AppiumBy.ACCESSIBILITY_ID, 'sendPaymentButton').click()
42
+ self.find(AppiumBy.ACCESSIBILITY_ID, 'Yes').click()
36
43
  # [END_DEMO_STEPS]
37
44
 
38
45
  def tearDown(self):
39
- print('Report URL: ' + self.driver.capabilities.get('digitalai:reportUrl', 'n/a'))
40
- self.driver.quit()
46
+ # Guarded: when setUp fails the driver is None (or the session is already dead) and an unguarded quit() would
47
+ # replace the real error with its own. quit() always runs so a half-created session releases its device.
48
+ if self.driver is None:
49
+ return
50
+ try:
51
+ print('Report URL: ' + str(self.driver.capabilities.get('digitalai:reportUrl', 'n/a')))
52
+ except Exception:
53
+ pass
54
+ try:
55
+ self.driver.quit()
56
+ finally:
57
+ self.driver = None
41
58
 
42
59
 
43
60
  if __name__ == '__main__':
@@ -7,7 +7,10 @@
7
7
  import unittest
8
8
  from appium import webdriver
9
9
  from selenium.webdriver.common.by import By
10
+ from appium.webdriver.common.appiumby import AppiumBy
10
11
  from appium.webdriver.webelement import WebElement
12
+ from selenium.webdriver.support.ui import WebDriverWait
13
+ from selenium.webdriver.support import expected_conditions as EC
11
14
 
12
15
 
13
16
  class LocalIosTest(unittest.TestCase):
@@ -25,7 +28,6 @@ class LocalIosTest(unittest.TestCase):
25
28
  'digitalai:deviceQuery': "@os='ios' and @category='[Enter PHONE/TABLET here]'",
26
29
  }
27
30
  self.driver = webdriver.Remote("[Enter Instance here]/wd/hub", desired_capabilities=desired_caps)
28
- self.driver.implicitly_wait(10)
29
31
 
30
32
  def _elem(self, raw):
31
33
  # JWP sessions return element dicts rather than WebElement objects.
@@ -35,27 +37,46 @@ class LocalIosTest(unittest.TestCase):
35
37
  return WebElement(self.driver, eid)
36
38
  return raw
37
39
 
40
+ def _wait(self, by, locator, timeout=20):
41
+ # Explicit wait (presence, not visibility: a JWP session returns a raw dict that has no is_displayed()).
42
+ # Used instead of an implicit wait — never mix the two.
43
+ return self._elem(WebDriverWait(self.driver, timeout).until(EC.presence_of_element_located((by, locator))))
44
+
45
+ def _find(self, accessibility_id):
46
+ # accessibility id == the element's name attribute on iOS (identifier, else label); the Grid accepts it too.
47
+ return self._wait(AppiumBy.ACCESSIBILITY_ID, accessibility_id)
48
+
38
49
  def _find_xpath(self, xpath):
39
- return self._elem(self.driver.find_element(By.XPATH, xpath))
50
+ return self._wait(By.XPATH, xpath)
40
51
 
41
52
  def testQuickStartIosNativeDemo(self):
42
53
  # [BEGIN_DEMO_STEPS]
43
- self._find_xpath("//*[@name='usernameTextField']").send_keys('company')
44
- self._find_xpath("//*[@name='passwordTextField']").send_keys('company')
45
- self._find_xpath("//*[@name='loginButton']").click()
46
- self._find_xpath("//*[@name='makePaymentButton']").click()
47
- self._find_xpath("//*[@name='phoneTextField']").send_keys('1234567')
48
- self._find_xpath("//*[@name='nameTextField']").send_keys('Jon Snow')
49
- self._find_xpath("//*[@name='amountTextField']").send_keys('50')
50
- self._find_xpath("//*[@name='countryButton']").click()
51
- self._find_xpath("//*[@name='Switzerland']").click()
52
- self._find_xpath("//*[@name='sendPaymentButton']").click()
53
- self._find_xpath("//*[@name='Yes']").click()
54
+ self._find("usernameTextField").send_keys('company')
55
+ self._find("passwordTextField").send_keys('company')
56
+ self._find("loginButton").click()
57
+ self._find("makePaymentButton").click()
58
+ self._find("phoneTextField").send_keys('1234567')
59
+ self._find("nameTextField").send_keys('Jon Snow')
60
+ self._find("amountTextField").send_keys('50')
61
+ self._find("countryButton").click()
62
+ self._find("Switzerland").click()
63
+ self._find("sendPaymentButton").click()
64
+ self._find("Yes").click()
54
65
  # [END_DEMO_STEPS]
55
66
 
56
67
  def tearDown(self):
57
- print('Report URL: ' + str(self.driver.desired_capabilities.get('digitalai:reportUrl', 'n/a')))
58
- self.driver.quit()
68
+ # Guarded: when setUp fails the driver is None (or the session is already dead) and an unguarded quit() would
69
+ # replace the real error with its own. quit() always runs so a half-created session releases its device.
70
+ if self.driver is None:
71
+ return
72
+ try:
73
+ print('Report URL: ' + str(self.driver.desired_capabilities.get('digitalai:reportUrl', 'n/a')))
74
+ except Exception:
75
+ pass
76
+ try:
77
+ self.driver.quit()
78
+ finally:
79
+ self.driver = None
59
80
 
60
81
 
61
82
  if __name__ == '__main__':
@@ -23,21 +23,38 @@ ${TEST_NAME} [Enter Test Name here]
23
23
  Quick Start iOS Native Demo
24
24
  Start Steps Group Test steps
25
25
  # [BEGIN_DEMO_STEPS]
26
- Input Text xpath=//*[@name='usernameTextField'] company
27
- Input Text xpath=//*[@name='passwordTextField'] company
28
- Click Element xpath=//*[@name='loginButton']
29
- Click Element xpath=//*[@name='makePaymentButton']
30
- Input Text xpath=//*[@name='phoneTextField'] 1234567
31
- Input Text xpath=//*[@name='nameTextField'] Jon Snow
32
- Input Text xpath=//*[@name='amountTextField'] 50
33
- Click Element xpath=//*[@name='countryButton']
34
- Click Element xpath=//*[@name='Switzerland']
35
- Click Element xpath=//*[@name='sendPaymentButton']
36
- Click Element xpath=//*[@name='Yes']
26
+ Wait And Input accessibility_id=usernameTextField company
27
+ Wait And Input accessibility_id=passwordTextField company
28
+ Wait And Click accessibility_id=loginButton
29
+ Wait And Click accessibility_id=makePaymentButton
30
+ Wait And Input accessibility_id=phoneTextField 1234567
31
+ Wait And Input accessibility_id=nameTextField Jon Snow
32
+ Wait And Input accessibility_id=amountTextField 50
33
+ Wait And Click accessibility_id=countryButton
34
+ Wait And Click accessibility_id=Switzerland
35
+ Wait And Click accessibility_id=sendPaymentButton
36
+ Wait And Click accessibility_id=Yes
37
37
  # [END_DEMO_STEPS]
38
38
  Stop Steps Group
39
39
 
40
40
  *** Keywords ***
41
+ Wait And Click
42
+ [Arguments] ${locator}
43
+ # Explicit wait before every interaction — AppiumLibrary's Click Element / Input Text do not wait on their own.
44
+ Wait Until Element Is Visible ${locator} 20s
45
+ Click Element ${locator}
46
+
47
+ Wait And Input
48
+ [Arguments] ${locator} ${text}
49
+ Wait Until Element Is Visible ${locator} 20s
50
+ Input Text ${locator} ${text}
51
+
52
+ # More AppiumLibrary keywords that fit a device farm (all built in, no extra library):
53
+ # Expect Text <text> visible timeout=20s polling assertion (also Expect Element <locator> visible)
54
+ # Scroll Element Into View <locator> reach content below the fold
55
+ # ${contexts}= Get Contexts / Switch To Context WEBVIEW_... / Switch To Context NATIVE_APP (hybrid screens)
56
+ # Background Application 5 lifecycle check
57
+
41
58
  Open Cloud Session
42
59
  Open Application ${REMOTE_URL} &{CAPABILITIES}
43
60
 
@@ -11,5 +11,8 @@ test {
11
11
  dependencies {
12
12
  testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: '5.10.2'
13
13
  testRuntimeOnly group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.10.2'
14
- testImplementation group: 'io.appium', name: 'java-client', version: '8.6.0'
14
+ // java-client 11 depends on selenium-api only ([4.50.0, 5.0)) and Gradle resolves the LOWEST version in a range —
15
+ // selenium-java pins the drivers and support classes explicitly
16
+ testImplementation group: 'io.appium', name: 'java-client', version: '11.0.0'
17
+ testImplementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '4.51.0'
15
18
  }
@@ -0,0 +1,45 @@
1
+ import io.appium.java_client.ios.IOSDriver;
2
+ import io.appium.java_client.ios.options.XCUITestOptions;
3
+ import org.junit.jupiter.api.*;
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
+ @BeforeEach
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
+ @AfterEach
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
+ }