-
-
Notifications
You must be signed in to change notification settings - Fork 75
/
Copy pathjetpack-compose-e2e-specs.js
78 lines (57 loc) · 2.51 KB
/
jetpack-compose-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
import { initSession, deleteSession, MOCHA_TIMEOUT } from '../helpers/session';
import { COMPOSE_CAPS } from '../desired';
describe('Jetpack Compose', 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);
// For SDK 23 and below Jetpack compose app crashes while running under instrumentation.
if (parseInt(process.env.ANDROID_SDK_VERSION, 10) <= 23) {
this.skip();
}
});
beforeEach(async function () {
driver = await initSession(COMPOSE_CAPS);
});
afterEach(async function () {
await deleteSession();
});
it('should find element by tag and text and click it', async function () {
let el = await driver.elementByXPath("//*[@text='Clickable Component']");
await driver.moveTo(el);
await el.click();
await driver.updateSettings({ driver: 'compose' });
let e = await driver.elementByTagName('lol');
await e.isDisplayed().should.eventually.be.true;
let elementWithDescription = await driver.elementByAccessibilityId('desc');
await elementWithDescription.text().should.eventually.equal('Click to see dialog');
await elementWithDescription.isDisplayed().should.eventually.be.true;
let clickableText = await driver.elementByLinkText('Click to see dialog');
await clickableText.click();
await driver.elementByLinkText('Congratulations! You just clicked the text successfully');
await driver.settings().should.eventually.eql({ driver: 'compose' });
});
it('should find element by xpath', async function () {
await driver.updateSettings({ driver: 'espresso' });
let el = await driver.elementByXPath("//*[@text='Clickable Component']");
await driver.moveTo(el);
await el.click();
await driver.updateSettings({ driver: 'compose' });
let e = await driver.elementByXPath("//*[@view-tag='lol']//*[@content-desc='desc']");
await e.text().should.eventually.equal('Click to see dialog');
});
it('should find elements', async function () {
await driver.updateSettings({ driver: 'espresso' });
let el = await driver.elementByXPath("//*[@text='Horizontal Carousel']");
await driver.moveTo(el);
await el.click();
await driver.updateSettings({ driver: 'compose' });
let e = await driver.elementsByLinkText('Grace Hopper');
e.length.should.be.eql(2);
await e[0].text().should.eventually.equal('Grace Hopper');
});
});