digital-ai-testing-mcp 2.1.1 → 2.2.1
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.
- package/README.md +18 -13
- package/dist/api/webdriver.d.ts +61 -3
- package/dist/api/webdriver.d.ts.map +1 -1
- package/dist/api/webdriver.js +673 -33
- package/dist/api/webdriver.js.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/tools/boilerplate-tools.d.ts +1 -1
- package/dist/tools/boilerplate-tools.d.ts.map +1 -1
- package/dist/tools/boilerplate-tools.js +217 -78
- package/dist/tools/boilerplate-tools.js.map +1 -1
- package/dist/tools/device-tools.d.ts +11 -0
- package/dist/tools/device-tools.d.ts.map +1 -1
- package/dist/tools/device-tools.js +25 -2
- package/dist/tools/device-tools.js.map +1 -1
- package/dist/tools/inspection-tools.d.ts.map +1 -1
- package/dist/tools/inspection-tools.js +219 -23
- package/dist/tools/inspection-tools.js.map +1 -1
- package/dist/tools/meta-tools.d.ts +1 -1
- package/dist/tools/meta-tools.d.ts.map +1 -1
- package/dist/tools/meta-tools.js +12 -1
- package/dist/tools/meta-tools.js.map +1 -1
- package/dist/tools/performance-tools.d.ts.map +1 -1
- package/dist/tools/performance-tools.js +6 -1
- package/dist/tools/performance-tools.js.map +1 -1
- package/dist/tools/reporting-tools.d.ts.map +1 -1
- package/dist/tools/reporting-tools.js +19 -1
- package/dist/tools/reporting-tools.js.map +1 -1
- package/dist/types/digital-ai.d.ts +10 -0
- package/dist/types/digital-ai.d.ts.map +1 -1
- package/dist/utils/test-orchestrator.d.ts +2 -0
- package/dist/utils/test-orchestrator.d.ts.map +1 -1
- package/dist/utils/test-orchestrator.js +2 -0
- package/dist/utils/test-orchestrator.js.map +1 -1
- package/package.json +3 -1
- package/resources/boilerplate/Android-Native/Java JUnit5/AndroidNative-oss-po.java +50 -0
- package/resources/boilerplate/Android-Native/Java JUnit5/AndroidNative-oss.java +23 -13
- package/resources/boilerplate/Android-Native/Java JUnit5/AndroidNative.java +19 -10
- package/resources/boilerplate/Android-Native/Java JUnit5/gradle-oss +4 -1
- package/resources/boilerplate/Android-Native/Java JUnit5/maven-oss +7 -1
- package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/AndroidNative-po.js +13 -0
- package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/AndroidNative.js +17 -11
- package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/wdio-oss.conf.js +7 -2
- package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/wdio.conf.js +10 -4
- package/resources/boilerplate/Android-Native/Python/AndroidNative-oss.py +30 -14
- package/resources/boilerplate/Android-Native/Python/AndroidNative.py +21 -5
- package/resources/boilerplate/Android-Native/Robot Framework/AndroidNative-oss.robot +28 -11
- package/resources/boilerplate/Android-Native/java TestNG/AndroidNative-oss-po.java +50 -0
- package/resources/boilerplate/Android-Native/java TestNG/AndroidNative-oss.java +23 -13
- package/resources/boilerplate/Android-Native/java TestNG/AndroidNative.java +19 -10
- package/resources/boilerplate/Android-Native/java TestNG/gradle-oss +4 -1
- package/resources/boilerplate/Android-Native/java TestNG/maven-oss +7 -1
- package/resources/boilerplate/iOS-Native/NodeJS (WebDriver)/iOSNative-po.js +13 -0
- package/resources/boilerplate/iOS-Native/NodeJS (WebDriver)/iOSNative.js +17 -11
- package/resources/boilerplate/iOS-Native/NodeJS (WebDriver)/wdio-oss.conf.js +4 -1
- package/resources/boilerplate/iOS-Native/NodeJS (WebDriver)/wdio.conf.js +2 -0
- package/resources/boilerplate/iOS-Native/Python/iOSNative-oss.py +31 -14
- package/resources/boilerplate/iOS-Native/Python/iOSNative.py +36 -15
- package/resources/boilerplate/iOS-Native/Robot Framework/iOSNative-oss.robot +28 -11
- package/resources/boilerplate/iOS-Native/java-JUnit5/gradle-oss +4 -1
- package/resources/boilerplate/iOS-Native/java-JUnit5/iOSNative-oss-po.java +47 -0
- package/resources/boilerplate/iOS-Native/java-JUnit5/iOSNative-oss.java +24 -13
- package/resources/boilerplate/iOS-Native/java-JUnit5/iOSNative.java +21 -11
- package/resources/boilerplate/iOS-Native/java-JUnit5/maven-oss +7 -1
- package/resources/boilerplate/iOS-Native/java-TestNG/gradle-oss +4 -1
- package/resources/boilerplate/iOS-Native/java-TestNG/iOSNative-oss-po.java +47 -0
- package/resources/boilerplate/iOS-Native/java-TestNG/iOSNative-oss.java +24 -13
- package/resources/boilerplate/iOS-Native/java-TestNG/iOSNative.java +21 -11
- package/resources/boilerplate/iOS-Native/java-TestNG/maven-oss +7 -1
- package/resources/boilerplate/shared/java-screens/AppScreen.java +29 -0
- package/resources/boilerplate/shared/java-screens/BaseScreen.java +42 -0
- package/resources/boilerplate/shared/java-screens/DashboardScreen.java +18 -0
- package/resources/boilerplate/shared/java-screens/LoginScreen.java +23 -0
- package/resources/boilerplate/shared/java-screens/PaymentScreen.java +34 -0
- package/resources/boilerplate/shared/node-screens/AppScreen.js +27 -0
- package/resources/boilerplate/shared/node-screens/DashboardScreen.js +13 -0
- package/resources/boilerplate/shared/node-screens/LoginScreen.js +18 -0
- package/resources/boilerplate/shared/node-screens/PaymentScreen.js +28 -0
- package/resources/boilerplate/shared/node-screens/PlaceholderScreen.js +21 -0
|
@@ -4,6 +4,9 @@ import io.appium.java_client.remote.AndroidMobileCapabilityType;
|
|
|
4
4
|
import io.appium.java_client.remote.MobileCapabilityType;
|
|
5
5
|
import org.junit.jupiter.api.*;
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
|
|
@@ -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
|
-
|
|
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
|
}
|
|
@@ -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>
|
|
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('LocalAndroidTest', () => {
|
|
4
|
+
it('quickStartAndroidNativeDemo', 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('LocalAndroidTest', () => {
|
|
2
2
|
it('quickStartAndroidNativeDemo', 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
|
|
12
|
+
const username = await find('id=com.experitest.ExperiBank:id/usernameTextField');
|
|
7
13
|
await username.setValue('company');
|
|
8
|
-
const password = await
|
|
14
|
+
const password = await find('id=com.experitest.ExperiBank:id/passwordTextField');
|
|
9
15
|
await password.setValue('company');
|
|
10
|
-
const loginButton = await
|
|
16
|
+
const loginButton = await find('id=com.experitest.ExperiBank:id/loginButton');
|
|
11
17
|
await loginButton.click();
|
|
12
|
-
const makePaymentButton = await
|
|
18
|
+
const makePaymentButton = await find('id=com.experitest.ExperiBank:id/makePaymentButton');
|
|
13
19
|
await makePaymentButton.click();
|
|
14
|
-
const phoneNumber = await
|
|
20
|
+
const phoneNumber = await find('id=com.experitest.ExperiBank:id/phoneTextField');
|
|
15
21
|
await phoneNumber.setValue('0541234567');
|
|
16
|
-
const name = await
|
|
22
|
+
const name = await find('id=com.experitest.ExperiBank:id/nameTextField');
|
|
17
23
|
await name.setValue('Jon Snow');
|
|
18
|
-
const amount = await
|
|
24
|
+
const amount = await find('id=com.experitest.ExperiBank:id/amountTextField');
|
|
19
25
|
await amount.setValue('50');
|
|
20
|
-
const countryButton = await
|
|
26
|
+
const countryButton = await find('id=com.experitest.ExperiBank:id/countryButton');
|
|
21
27
|
await countryButton.click();
|
|
22
|
-
const country = await
|
|
28
|
+
const country = await find('//*[@text="Switzerland"]');
|
|
23
29
|
await country.click();
|
|
24
|
-
const sendPaymentButton = await
|
|
30
|
+
const sendPaymentButton = await find('id=com.experitest.ExperiBank:id/sendPaymentButton');
|
|
25
31
|
await sendPaymentButton.click();
|
|
26
|
-
const yesButton = await
|
|
32
|
+
const yesButton = await find('id=android:id/button1');
|
|
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/AndroidNative.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: 'ANDROID',
|
|
@@ -18,11 +20,14 @@ exports.config = {
|
|
|
18
20
|
'appium:autoDismissAlerts': true,
|
|
19
21
|
'appium:autoGrantPermissions': true,
|
|
20
22
|
// System-level overlays (charging dialog, USB prompt) are NOT caught by autoDismissAlerts.
|
|
21
|
-
// To clear them, run in an afterTest hook
|
|
23
|
+
// To clear them, run in an afterTest hook (the object is the ONE execute argument — not wrapped in an array):
|
|
24
|
+
// browser.execute('mobile: shell', {command: 'am', args: ['broadcast', '-a', 'android.intent.action.CLOSE_SYSTEM_DIALOGS']})
|
|
25
|
+
// or, where the cloud does not enable the adb_shell feature: browser.execute('mobile: broadcast', {action: 'android.intent.action.CLOSE_SYSTEM_DIALOGS'})
|
|
22
26
|
}],
|
|
23
27
|
logLevel: 'info',
|
|
24
28
|
bail: 0,
|
|
25
|
-
|
|
29
|
+
// Native apps on a device farm need longer than the wdio default: the first $() races app install + launch.
|
|
30
|
+
waitforTimeout: 45000,
|
|
26
31
|
connectionRetryTimeout: 120000,
|
|
27
32
|
connectionRetryCount: 3,
|
|
28
33
|
framework: 'mocha',
|
|
@@ -8,6 +8,8 @@ exports.config = {
|
|
|
8
8
|
path: '/wd/hub',
|
|
9
9
|
specs: ['./test/specs/AndroidNative.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: 'ANDROID',
|
|
@@ -19,14 +21,18 @@ exports.config = {
|
|
|
19
21
|
'appium:appPackage': 'com.experitest.ExperiBank',
|
|
20
22
|
'appium:appActivity': '.LoginActivity',
|
|
21
23
|
'digitalai:deviceQuery': "@os='android' and @category='[Enter PHONE/TABLET here]'",
|
|
22
|
-
'
|
|
23
|
-
'
|
|
24
|
+
// wdio 7's validator rejects these unprefixed too ("Invalid or unsupported WebDriver capabilities", live 2026-10-17).
|
|
25
|
+
'appium:autoDismissAlerts': true,
|
|
26
|
+
'appium:autoGrantPermissions': true,
|
|
24
27
|
// System-level overlays (charging dialog, USB prompt) are NOT caught by autoDismissAlerts.
|
|
25
|
-
// To clear them, run in an afterTest hook
|
|
28
|
+
// To clear them, run in an afterTest hook (the object is the ONE execute argument — not wrapped in an array):
|
|
29
|
+
// browser.execute('mobile: shell', {command: 'am', args: ['broadcast', '-a', 'android.intent.action.CLOSE_SYSTEM_DIALOGS']})
|
|
30
|
+
// or, where the cloud does not enable the adb_shell feature: browser.execute('mobile: broadcast', {action: 'android.intent.action.CLOSE_SYSTEM_DIALOGS'})
|
|
26
31
|
}],
|
|
27
32
|
logLevel: 'info',
|
|
28
33
|
bail: 0,
|
|
29
|
-
|
|
34
|
+
// Native apps on a device farm need longer than the wdio default: the first $() races app install + launch.
|
|
35
|
+
waitforTimeout: 45000,
|
|
30
36
|
connectionRetryTimeout: 120000,
|
|
31
37
|
connectionRetryCount: 3,
|
|
32
38
|
framework: 'mocha',
|
|
@@ -2,6 +2,8 @@ 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 selenium.webdriver.support.ui import WebDriverWait
|
|
6
|
+
from selenium.webdriver.support import expected_conditions as EC
|
|
5
7
|
|
|
6
8
|
|
|
7
9
|
class LocalAndroidTest(unittest.TestCase):
|
|
@@ -21,28 +23,42 @@ class LocalAndroidTest(unittest.TestCase):
|
|
|
21
23
|
options.set_capability('autoDismissAlerts', True)
|
|
22
24
|
options.set_capability('autoGrantPermissions', True)
|
|
23
25
|
self.driver = webdriver.Remote("[Enter Instance here]/wd/hub", options=options)
|
|
24
|
-
self.driver.implicitly_wait(10)
|
|
25
26
|
# System-level overlays (charging dialog, USB prompt) are NOT caught by autoDismissAlerts.
|
|
26
27
|
# If they block tests: self.driver.execute_script("mobile: shell", {"command": "am", "args": ["broadcast", "-a", "android.intent.action.CLOSE_SYSTEM_DIALOGS"]})
|
|
27
28
|
|
|
29
|
+
def find(self, by, locator, timeout=20):
|
|
30
|
+
# Explicit wait: polls until the element is visible, then returns it. Used instead of an implicit wait — never
|
|
31
|
+
# mix the two (every miss then waits implicit + explicit, and the real timeout becomes unpredictable).
|
|
32
|
+
return WebDriverWait(self.driver, timeout).until(EC.visibility_of_element_located((by, locator)))
|
|
33
|
+
|
|
28
34
|
def testQuickStartAndroidNativeDemo(self):
|
|
29
35
|
# [BEGIN_DEMO_STEPS]
|
|
30
|
-
self.
|
|
31
|
-
self.
|
|
32
|
-
self.
|
|
33
|
-
self.
|
|
34
|
-
self.
|
|
35
|
-
self.
|
|
36
|
-
self.
|
|
37
|
-
self.
|
|
38
|
-
self.
|
|
39
|
-
self.
|
|
40
|
-
self.
|
|
36
|
+
self.find(By.ID, "com.experitest.ExperiBank:id/usernameTextField").send_keys('company')
|
|
37
|
+
self.find(By.ID, "com.experitest.ExperiBank:id/passwordTextField").send_keys('company')
|
|
38
|
+
self.find(By.ID, "com.experitest.ExperiBank:id/loginButton").click()
|
|
39
|
+
self.find(By.ID, "com.experitest.ExperiBank:id/makePaymentButton").click()
|
|
40
|
+
self.find(By.ID, "com.experitest.ExperiBank:id/phoneTextField").send_keys('1234567')
|
|
41
|
+
self.find(By.ID, "com.experitest.ExperiBank:id/nameTextField").send_keys('Jon Snow')
|
|
42
|
+
self.find(By.ID, "com.experitest.ExperiBank:id/amountTextField").send_keys('50')
|
|
43
|
+
self.find(By.ID, "com.experitest.ExperiBank:id/countryButton").click()
|
|
44
|
+
self.find(By.XPATH, "//*[@text='Switzerland']").click()
|
|
45
|
+
self.find(By.ID, "com.experitest.ExperiBank:id/sendPaymentButton").click()
|
|
46
|
+
self.find(By.ID, "android:id/button1").click()
|
|
41
47
|
# [END_DEMO_STEPS]
|
|
42
48
|
|
|
43
49
|
def tearDown(self):
|
|
44
|
-
|
|
45
|
-
|
|
50
|
+
# Guarded: when setUp fails the driver is None (or the session is already dead) and an unguarded quit() would
|
|
51
|
+
# replace the real error with its own. quit() always runs so a half-created session releases its device.
|
|
52
|
+
if self.driver is None:
|
|
53
|
+
return
|
|
54
|
+
try:
|
|
55
|
+
print('Report URL: ' + str(self.driver.capabilities.get('digitalai:reportUrl', 'n/a')))
|
|
56
|
+
except Exception:
|
|
57
|
+
pass
|
|
58
|
+
try:
|
|
59
|
+
self.driver.quit()
|
|
60
|
+
finally:
|
|
61
|
+
self.driver = None
|
|
46
62
|
|
|
47
63
|
|
|
48
64
|
if __name__ == '__main__':
|
|
@@ -8,6 +8,8 @@ import unittest
|
|
|
8
8
|
from appium import webdriver
|
|
9
9
|
from selenium.webdriver.common.by import By
|
|
10
10
|
from appium.webdriver.webelement import WebElement
|
|
11
|
+
from selenium.webdriver.support.ui import WebDriverWait
|
|
12
|
+
from selenium.webdriver.support import expected_conditions as EC
|
|
11
13
|
|
|
12
14
|
|
|
13
15
|
class LocalAndroidTest(unittest.TestCase):
|
|
@@ -28,7 +30,6 @@ class LocalAndroidTest(unittest.TestCase):
|
|
|
28
30
|
'autoGrantPermissions': True,
|
|
29
31
|
}
|
|
30
32
|
self.driver = webdriver.Remote("[Enter Instance here]/wd/hub", desired_capabilities=desired_caps)
|
|
31
|
-
self.driver.implicitly_wait(10)
|
|
32
33
|
# System-level overlays (charging dialog, USB prompt) are NOT caught by autoDismissAlerts.
|
|
33
34
|
# If they block tests: self.driver.execute_script("mobile: shell", {"command": "am", "args": ["broadcast", "-a", "android.intent.action.CLOSE_SYSTEM_DIALOGS"]})
|
|
34
35
|
|
|
@@ -40,11 +41,16 @@ class LocalAndroidTest(unittest.TestCase):
|
|
|
40
41
|
return WebElement(self.driver, eid)
|
|
41
42
|
return raw
|
|
42
43
|
|
|
44
|
+
def _wait(self, by, locator, timeout=20):
|
|
45
|
+
# Explicit wait (presence, not visibility: a JWP session returns a raw dict that has no is_displayed()).
|
|
46
|
+
# Used instead of an implicit wait — never mix the two.
|
|
47
|
+
return self._elem(WebDriverWait(self.driver, timeout).until(EC.presence_of_element_located((by, locator))))
|
|
48
|
+
|
|
43
49
|
def _find(self, resource_id):
|
|
44
|
-
return self.
|
|
50
|
+
return self._wait(By.ID, f"com.experitest.ExperiBank:id/{resource_id}")
|
|
45
51
|
|
|
46
52
|
def _find_xpath(self, xpath):
|
|
47
|
-
return self.
|
|
53
|
+
return self._wait(By.XPATH, xpath)
|
|
48
54
|
|
|
49
55
|
def testQuickStartAndroidNativeDemo(self):
|
|
50
56
|
# [BEGIN_DEMO_STEPS]
|
|
@@ -61,8 +67,18 @@ class LocalAndroidTest(unittest.TestCase):
|
|
|
61
67
|
# [END_DEMO_STEPS]
|
|
62
68
|
|
|
63
69
|
def tearDown(self):
|
|
64
|
-
|
|
65
|
-
|
|
70
|
+
# Guarded: when setUp fails the driver is None (or the session is already dead) and an unguarded quit() would
|
|
71
|
+
# replace the real error with its own. quit() always runs so a half-created session releases its device.
|
|
72
|
+
if self.driver is None:
|
|
73
|
+
return
|
|
74
|
+
try:
|
|
75
|
+
print('Report URL: ' + str(self.driver.desired_capabilities.get('digitalai:reportUrl', 'n/a')))
|
|
76
|
+
except Exception:
|
|
77
|
+
pass
|
|
78
|
+
try:
|
|
79
|
+
self.driver.quit()
|
|
80
|
+
finally:
|
|
81
|
+
self.driver = None
|
|
66
82
|
|
|
67
83
|
|
|
68
84
|
if __name__ == '__main__':
|
|
@@ -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
|
|
29
|
-
Input
|
|
30
|
-
Click
|
|
31
|
-
Click
|
|
32
|
-
Input
|
|
33
|
-
Input
|
|
34
|
-
Input
|
|
35
|
-
Click
|
|
36
|
-
Click
|
|
37
|
-
Click
|
|
38
|
-
Click
|
|
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,50 @@
|
|
|
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 screens.*;
|
|
6
|
+
|
|
7
|
+
import java.net.MalformedURLException;
|
|
8
|
+
import java.net.URI;
|
|
9
|
+
|
|
10
|
+
/** Page-object layout: the screens live in the screens package (BaseScreen + one class per screen); the test reads as the flow. */
|
|
11
|
+
public class LocalAndroidTest {
|
|
12
|
+
|
|
13
|
+
private AndroidDriver driver;
|
|
14
|
+
|
|
15
|
+
@BeforeMethod
|
|
16
|
+
public void setUp() throws MalformedURLException {
|
|
17
|
+
UiAutomator2Options options = new UiAutomator2Options();
|
|
18
|
+
options.setCapability("digitalai:testName", "[Enter Test Name here]");
|
|
19
|
+
options.setCapability("digitalai:accessKey", "[Enter Your Access key here]");
|
|
20
|
+
options.setCapability("digitalai:deviceQuery", "@os='android' and @category='[Enter PHONE/TABLET here]'");
|
|
21
|
+
options.setApp("cloud:com.experitest.ExperiBank/.LoginActivity");
|
|
22
|
+
options.setAppPackage("com.experitest.ExperiBank");
|
|
23
|
+
options.setAppActivity(".LoginActivity");
|
|
24
|
+
options.setCapability("autoDismissAlerts", true);
|
|
25
|
+
options.setCapability("autoGrantPermissions", true);
|
|
26
|
+
driver = new AndroidDriver(URI.create("[Enter Instance here]/wd/hub").toURL(), options);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@Test
|
|
30
|
+
public void quickStartAndroidNativeDemo() {
|
|
31
|
+
// [BEGIN_DEMO_STEPS]
|
|
32
|
+
new LoginScreen(driver).login("company", "company")
|
|
33
|
+
.makePayment()
|
|
34
|
+
.fillPayment("0501234567", "John Snow", "50", "Switzerland")
|
|
35
|
+
.sendAndConfirm();
|
|
36
|
+
// [END_DEMO_STEPS]
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@AfterMethod
|
|
40
|
+
public void tearDown() {
|
|
41
|
+
if (driver == null) return;
|
|
42
|
+
try {
|
|
43
|
+
System.out.println("Report URL: " + driver.getCapabilities().getCapability("digitalai:reportUrl"));
|
|
44
|
+
System.out.println("Report Test ID: " + driver.getCapabilities().getCapability("digitalai:reportTestId"));
|
|
45
|
+
} catch (Exception ignored) {}
|
|
46
|
+
try {
|
|
47
|
+
driver.quit();
|
|
48
|
+
} catch (Exception ignored) {}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -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.
|
|
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(
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
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>
|
|
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
|
|
12
|
+
const username = await find('~usernameTextField');
|
|
7
13
|
await username.setValue('company');
|
|
8
|
-
const password = await
|
|
14
|
+
const password = await find('~passwordTextField');
|
|
9
15
|
await password.setValue('company');
|
|
10
|
-
const loginButton = await
|
|
16
|
+
const loginButton = await find('~loginButton');
|
|
11
17
|
await loginButton.click();
|
|
12
|
-
const makePaymentButton = await
|
|
18
|
+
const makePaymentButton = await find('~makePaymentButton');
|
|
13
19
|
await makePaymentButton.click();
|
|
14
|
-
const phoneNumber = await
|
|
20
|
+
const phoneNumber = await find('~phoneTextField');
|
|
15
21
|
await phoneNumber.setValue('0541234567');
|
|
16
|
-
const name = await
|
|
22
|
+
const name = await find('~nameTextField');
|
|
17
23
|
await name.setValue('Jon Snow');
|
|
18
|
-
const amount = await
|
|
24
|
+
const amount = await find('~amountTextField');
|
|
19
25
|
await amount.setValue('50');
|
|
20
|
-
const countryButton = await
|
|
26
|
+
const countryButton = await find('~countryButton');
|
|
21
27
|
await countryButton.click();
|
|
22
|
-
const country = await
|
|
28
|
+
const country = await find('~Switzerland');
|
|
23
29
|
await country.click();
|
|
24
|
-
const sendPaymentButton = await
|
|
30
|
+
const sendPaymentButton = await find('~sendPaymentButton');
|
|
25
31
|
await sendPaymentButton.click();
|
|
26
|
-
const yesButton = await
|
|
32
|
+
const yesButton = await find('~Yes');
|
|
27
33
|
await yesButton.click();
|
|
28
34
|
// [END_DEMO_STEPS]
|
|
29
35
|
}
|