-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathfind-e2e-specs.js
114 lines (95 loc) · 3.65 KB
/
find-e2e-specs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import _ from 'lodash';
import { remote } from 'webdriverio';
import { HOST, PORT, MOCHA_TIMEOUT, TEXT_EDIT_BUNDLE_ID } from '../utils';
const CAPS = {
platformName: 'mac',
'appium:automationName': 'mac2',
'appium:bundleId': TEXT_EDIT_BUNDLE_ID,
};
describe('Mac2Driver - find elements', function () {
this.timeout(MOCHA_TIMEOUT);
let driver;
let chai;
before(async function () {
chai = await import('chai');
const chaiAsPromised = await import('chai-as-promised');
chai.should();
chai.use(chaiAsPromised.default);
});
beforeEach(async function () {
driver = await remote({
hostname: HOST,
port: PORT,
capabilities: CAPS,
});
});
afterEach(async function () {
if (driver) {
try {
await driver.deleteSession();
} finally {
driver = null;
}
}
});
it('should find by accessibility id', async function () {
const el = await driver.findElement('accessibility id', 'duplicateDocument:');
el.should.exist;
});
it('should find multiple by accessibility id', async function () {
const els = await driver.findElements('accessibility id', 'duplicateDocument:');
els.length.should.eql(1);
await driver.getElementAttribute(els[0], 'identifier').should.eventually.eql('duplicateDocument:');
});
it('should find by class name', async function () {
const el = await driver.findElement('class name', 'XCUIElementTypeTextView');
el.should.exist;
});
it('should find by multiple by class name', async function () {
const els = await driver.findElement('class name', 'XCUIElementTypeRulerMarker');
els.length.should.be.above(1);
});
it('should find by predicate', async function () {
const els = await driver.findElements('-ios predicate string', 'elementType == 2');
els.length.should.be.above(0);
await driver.getElementAttribute(els[0], 'elementType').should.eventually.eql('2');
});
it('should find by class chain', async function () {
const els = await driver.findElements('-ios class chain', '**/XCUIElementTypePopUpButton');
els.length.should.be.above(0);
await driver.getElementAttribute(_.first(els), 'elementType').should.eventually.eql('14');
await driver.getElementAttribute(_.last(els), 'elementType').should.eventually.eql('14');
});
it('should find by xpath', async function () {
const el = await driver.findElement(
'xpath',
'//XCUIElementTypePopUpButton[@value="Regular" and @label="type face"]'
);
el.should.exist;
});
it('should find by absolute xpath', async function () {
// xpath index starts from 1
const el = await driver.findElement(
'xpath',
'/XCUIElementTypeApplication[@title="TextEdit"]/XCUIElementTypeWindow[1]/XCUIElementTypeScrollView[1]'
);
el.should.exist;
});
it('should find multiple by xpath', async function () {
const els = await driver.findElements(
'xpath',
'//XCUIElementTypePopUpButton[@enabled="true"]'
);
els.length.should.be.above(1);
await driver.getElementAttribute(_.first(els), 'elementType').should.eventually.eql('14');
await driver.getElementAttribute(_.last(els), 'elementType').should.eventually.eql('14');
});
it('should find subelements', async function () {
const el = await driver.findElement('class name', 'XCUIElementTypeRuler');
el.should.exist;
const subEls = await driver.findElementsFromElement(el, '-ios class chain', '*');
subEls.length.should.be.above(1);
await driver.getElementAttribute(_.first(subEls), 'elementType').should.eventually.eql('72');
await driver.getElementAttribute(_.last(subEls), 'elementType').should.eventually.eql('72');
});
});