-
Notifications
You must be signed in to change notification settings - Fork 0
/
menuTabsHeaders.js
66 lines (52 loc) · 2.23 KB
/
menuTabsHeaders.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
const {Builder, By, until} = require('selenium-webdriver');
const test = require('selenium-webdriver/testing');
const expect = require('chai').expect;
test.describe('Admin page', function() {
let driver;
const adminPage = 'http://10.0.9.48/litecart/admin/'; //!!!CHANGE TO LOCALHOST
const adminLogin = 'admin';
const adminPass = 'admin';
test.before(function *() {
driver = yield new Builder()
.forBrowser('chrome')
.build();
});
test.it('Check menu tabs headers', function*() {
function getFirstLevelElements() {
return driver.findElements(By.xpath('//*[@id="app-"]/a/*[contains(@class, "name")]'));
}
function getSecondLevelElements() {
return driver.findElements(By.xpath('//*[contains(@class, "docs")]//*[contains(@class, "name")]'));
}
function isHeader(currentLocator) {
return driver.findElement(By.css('#content h1')).then(()=>{
expect(true).to.equal(true, 'Не отображается заголовок при переходе по ссылке ' + currentLocator);
}).catch(()=>{
expect(false).to.equal(true, 'Не отображается заголовок при переходе по ссылке ' + currentLocator);
})
}
function checkInsideElements() {
getSecondLevelElements()
.then(secondLevelElements=>{
secondLevelElements.forEach((_, index)=>{
index++;
let currentLocator = '(//*[contains(@class, "docs")]//*[contains(@class, "name")])['+ index +']';
driver.findElement(By.xpath(currentLocator)).click();
isHeader(currentLocator);
});});
}
driver.get(adminPage);
driver.findElement(By.name('username')).sendKeys(adminLogin);
driver.findElement(By.name('password')).sendKeys(adminPass);
driver.findElement(By.name('login')).click();
let firstLevelElements = yield getFirstLevelElements();
firstLevelElements.forEach((_,index)=>{
index ++;
let currentLocator = '(//*[@id="app-"]/a/*[contains(@class, "name")])['+ index +']';
driver.findElement(By.xpath(currentLocator)).click();
isHeader(currentLocator);
checkInsideElements();
});
});
test.after(() => driver.quit());
});