-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.e2e.ts
37 lines (26 loc) · 1.13 KB
/
example.e2e.ts
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
import LoginPage from '../pageobjects/login.page';
import { ChainablePromiseElement } from 'webdriverio';
import loginPage from '../pageobjects/login.page';
import securePage from '../pageobjects/secure.page';
class ButtonWebElement {
constructor(public element: ChainablePromiseElement<Promise<WebdriverIO.Element>>) {}
async getPassword() {
return (await this.element).$('#password');
}
}
describe('My Login application', () => {
it('should login with valid credentials', async () => {
loginPage.open();
browser.addCommand('example', (selector: string) => {
return $(selector);
}, true);
const body = await $('body');
await (await body.example('#username')).setValue('invalid');
const el1 = new ButtonWebElement($('body'));
await (await el1.getPassword()).setValue('some value');
const el2 = new ButtonWebElement(body.example('#content'));
await (await el2.getPassword()).setValue('some other value');
await loginPage.btnSubmit.click();
await securePage.flashAlert.waitForDisplayed();
});
});