Skip to content

Commit 324f6e8

Browse files
committed
rename to webdriver2 and support mobileextension
1 parent 682e639 commit 324f6e8

14 files changed

+6222
-231
lines changed

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
example

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
**Make selenium-webdriver to drive appium to do native app testing**
1+
* A wrapper of Selenium-webdriver
2+
* A bridge to drive appium to support native app automation
3+
* Simple logic to wait for element to show up
4+
* Support PageObject pattern. Easy to wait for pages to load complete or navigate among pages

example/__tests__/calculator.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,66 @@
1-
import { createAppiumWebDriver, windowsNativeAppCapabilities } from 'selenium-appium'
1+
import { createWebDriver2, windowsNativeAppCapabilities } from 'selenium-appium'
22
import { By } from 'selenium-webdriver'
33
jest.setTimeout(50000);
44

55
const calculatorAppId = 'Microsoft.WindowsCalculator_8wekyb3d8bbwe!App'
6-
const driver = createAppiumWebDriver(windowsNativeAppCapabilities(calculatorAppId))
6+
const driver = createWebDriver2(windowsNativeAppCapabilities(calculatorAppId))
77

88
beforeAll(() => {
9-
return driver.start();
9+
return driver.start();
1010
});
1111

1212
afterAll(() => {
1313
return driver.stop();
1414
});
1515

1616
async function getCalculatorResultText() {
17-
const text = await driver.getByAccessibilityId('CalculatorResults').getText();
17+
const text = await driver.getByNativeAccessibilityId('CalculatorResults').getText();
1818
return text.replace('Display is', '').trim();
1919
}
2020

2121
describe('Addition', () => {
2222
// Applies only to tests in this describe block
2323
beforeEach(async () => {
24-
await driver.getByName('Clear').clear();
24+
await driver.getByNativeName('Clear').clear();
2525
});
2626

2727
test('Addition', async () => {
2828
// Find the buttons by their names and click them in sequence to perform 1 + 7 = 8
29-
await driver.getByName('One').click();
30-
await driver.getByName('Plus').click();
31-
await driver.getByName('Seven').click();
32-
await driver.getByName('Equals').click();
29+
await driver.getByNativeName('One').click();
30+
await driver.getByNativeName('Plus').click();
31+
await driver.getByNativeName('Seven').click();
32+
await driver.getByNativeName('Equals').click();
3333
expect(await getCalculatorResultText()).toBe('8');
3434
});
3535

3636
test('Division', async () => {
3737
// Find the buttons by their accessibility ids and click them in sequence to perform 88 / 11 = 8
38-
await driver.getByAccessibilityId('num8Button').click();
39-
await driver.getByAccessibilityId('num8Button').click();
40-
await driver.getByAccessibilityId('divideButton').click();
41-
await driver.getByAccessibilityId('num1Button').click();
42-
await driver.getByAccessibilityId('num1Button').click();
43-
await driver.getByAccessibilityId('equalButton').click();
38+
await driver.getByNativeAccessibilityId('num8Button').click();
39+
await driver.getByNativeAccessibilityId('num8Button').click();
40+
await driver.getByNativeAccessibilityId('divideButton').click();
41+
await driver.getByNativeAccessibilityId('num1Button').click();
42+
await driver.getByNativeAccessibilityId('num1Button').click();
43+
await driver.getByNativeAccessibilityId('equalButton').click();
4444
expect(await getCalculatorResultText()).toBe('8');
4545
});
4646

4747
test('Multiplication', async () => {
4848
// Find the buttons by their names using XPath and click them in sequence to perform 9 x 9 = 81
49-
await driver.get(By.xpath("//Button[@Name='Nine']")).click();
50-
await driver.get(By.xpath("//Button[@Name='Multiply by']")).click();
51-
await driver.get(By.xpath("//Button[@Name='Nine']")).click();
52-
await driver.get(By.xpath("//Button[@Name='Equals']")).click();
49+
await driver.getBy(By.xpath("//Button[@Name='Nine']")).click();
50+
await driver.getBy(By.xpath("//Button[@Name='Multiply by']")).click();
51+
await driver.getBy(By.xpath("//Button[@Name='Nine']")).click();
52+
await driver.getBy(By.xpath("//Button[@Name='Equals']")).click();
5353
expect(await getCalculatorResultText()).toBe('81');
5454
});
5555

5656

5757

5858
test('Subtraction', async () => {
5959
// Find the buttons by their accessibility ids using XPath and click them in sequence to perform 9 - 1 = 8
60-
await driver.get(By.xpath("//Button[@AutomationId=\"num9Button\"]")).click();
61-
await driver.get(By.xpath("//Button[@AutomationId=\"minusButton\"]")).click();
62-
await driver.get(By.xpath("//Button[@AutomationId=\"num1Button\"]")).click();
63-
await driver.get(By.xpath("//Button[@AutomationId=\"equalButton\"]")).click();
60+
await driver.getBy(By.xpath("//Button[@AutomationId=\"num9Button\"]")).click();
61+
await driver.getBy(By.xpath("//Button[@AutomationId=\"minusButton\"]")).click();
62+
await driver.getBy(By.xpath("//Button[@AutomationId=\"num1Button\"]")).click();
63+
await driver.getBy(By.xpath("//Button[@AutomationId=\"equalButton\"]")).click();
6464
expect(await getCalculatorResultText()).toBe('8');
6565
});
6666
});

0 commit comments

Comments
 (0)