-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathutam-portal.spec.js
90 lines (71 loc) · 3.78 KB
/
utam-portal.spec.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
/*
* Copyright (c) 2021, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
// to run:
// yarn test --spec force-app/test/utam-portal.spec.js
import UtamDevHome from 'utam-preview/pageObjects/utamDevHome';
import Dummy from 'utam-preview/pageObjects/dummy';
import NullableExample from 'utam-preview/pageObjects/nullableExample';
describe('Test utam.dev portal', () => {
beforeEach(async () => {
console.log('Navigate to portal');
await browser.navigateTo('https://utam.dev');
});
it('Menu links navigation', async () => {
console.log('Load Home Page');
const homePage = await utam.load(UtamDevHome);
const menuItems = await homePage.getMenuItems();
expect(menuItems.length).toBe(6);
console.log('Click Grammar menu item and check navigation');
await (await homePage.getGrammarMenuItem()).click();
expect(await browser.getUrl()).toBe('https://utam.dev/grammar/spec');
});
it('Validate root element presence', async () => {
console.log('Assert that a root page is not loaded');
const domDocument = utam.getCurrentDocument();
// random root page object that we know is not present
expect(await domDocument.containsObject(Dummy)).toBeFalse();
console.log('Assert that a root element with a given locator is not present');
expect(await domDocument.containsElement(utam.By.css('idonotexist'))).toBeFalse();
});
it('Checking absence of the elements on the page', async () => {
console.log('Load Home Page');
const homePage = await utam.load(NullableExample);
console.log('Non existing nullable basic element is returned as null');
expect(await homePage.getNullableBasicElement()).toBeNull();
console.log('Non existing nullable basic elements list is returned as null');
expect(await homePage.getNullableBasicElementList()).toBeNull();
console.log('Non existing nullable custom element is returned as null');
expect(await homePage.getNullableCustomElement()).toBeNull();
console.log('Non existing nullable custom elements list is returned as null');
expect(await homePage.getNullableCustomElementList()).toBeNull();
console.log('Nullable element scoped inside non existing nullable basic element is returned as null');
expect(await homePage.getScopedInsideNullable()).toBeNull();
});
it('Test with stale elements', async () => {
console.log('Confirm that everything is present and visible');
let homePage = await utam.load(UtamDevHome);
await homePage.waitForVisible();
expect(await homePage.isPresent()).toBeTrue();
expect(await homePage.isVisible()).toBeTrue();
console.log('Get home page content, save as a variable');
let pageContent = await homePage.getContent();
expect(await pageContent.isPresent()).toBeTrue();
console.log('Reload web page by navigating to its URL again');
await browser.navigateTo('https://utam.dev');
console.log('Because we reloaded content, all elements became stale');
await homePage.waitForAbsence();
expect(await homePage.isPresent()).toBeFalse();
await pageContent.waitForAbsence();
expect(await pageContent.isPresent()).toBeFalse();
console.log('Reload the root to invoke Driver.findElement');
homePage = await utam.load(UtamDevHome);
expect(await homePage.isPresent()).toBeTrue();
console.log('Call getter to invoke Element.findElement and assign new variable');
pageContent = await homePage.getContent();
expect(await pageContent.isPresent()).toBeTrue();
});
});