-
Notifications
You must be signed in to change notification settings - Fork 3
/
find-e2e-specs.js
84 lines (73 loc) · 2.15 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
// import _ from 'lodash';
import { remote } from 'webdriverio';
import { startServer } from '../../lib/server';
import chaiAsPromised from 'chai-as-promised';
import chai from 'chai';
import { HOST, PORT, MOCHA_TIMEOUT, APP_NAME } from '../utils';
chai.should();
chai.use(chaiAsPromised);
const CAPS = {
platformName: 'linux',
'appium:appName': APP_NAME
};
describe('AtSpi2Driver - find elements', function () {
this.timeout(MOCHA_TIMEOUT);
let server;
let driver;
before(async function () {
server = await startServer(PORT, HOST);
});
after(async function () {
if (server) {
await server.close();
server = null;
}
});
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 name', async function () {
const el = await driver.findElement('name', 'Find');
el.should.exist;
});
it('should find multiple by name', async function () {
const els = await driver.findElements('name', 'Find');
els.length.should.eql(1);
await driver.getElementAttribute(els[0].ELEMENT, 'name').should.eventually.eql('Find');
});
it('should find by xpath', async function () {
const el = await driver.findElement(
'xpath',
'//toggle-button[@name="Find"]'
);
el.should.exist;
});
it('should find multiple by xpath', async function () {
const els = await driver.findElements(
'xpath',
'//toggle-button[@name="Find"]'
);
els.length.should.eql(1);
await driver.getElementAttribute(els[0].ELEMENT, 'name').should.eventually.eql('Find');
});
it('should find subelements', async function () {
const el = await driver.findElement('xpath', '//document-web');
el.should.exist;
const subEls = await driver.findElementsFromElement(el.ELEMENT, 'xpath', '//image[@name="Ubuntu Logo"]');
subEls.length.should.eql(1);
await driver.getElementAttribute(subEls[0].ELEMENT, 'tag').should.eventually.eql('img');
});
});