-
Notifications
You must be signed in to change notification settings - Fork 0
/
browserLogsChecking.js
73 lines (58 loc) · 2.21 KB
/
browserLogsChecking.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
const {Builder, By, until} = require('selenium-webdriver');
const test = require('selenium-webdriver/testing');
const expect = require('chai').expect;
test.describe('Browser logs', function() {
let driver;
const homePage = 'http://172.14.14.128/litecart/'; //!!!CHANGE TO LOCALHOST
const adminPage = homePage + 'admin/';
const adminLogin = 'admin';
const adminPass = 'admin';
function adminLogon() {
driver.get(adminPage);
driver.findElement(By.name('username')).sendKeys(adminLogin);
driver.findElement(By.name('password')).sendKeys(adminPass);
driver.findElement(By.name('login')).click();
}
test.before(function *() {
driver = yield new Builder()
.forBrowser('chrome')
.build();
adminLogon();
});
test.it('Checks browser logs', function*() {
const catalogPage = homePage + 'admin/?app=catalog&doc=catalog&category_id=1';
function _getByName(name) {
return driver.findElement(By.name(name))
}
function _getByCss(name) {
return driver.findElement(By.css(name))
}
function _getMayByCss(name) {
return driver.findElements(By.css(name))
}
function _getByXpath(name) {
return driver.findElement(By.xpath(name))
}
function getCatalogPage() {
return driver.get(catalogPage);
}
function getProductsNumber() {
return _getMayByCss('.row')
.then(rows => { return rows.length })
}
function openProduct(row) {
return _getByCss('tbody .row:nth-child('+ row +') a').click();
}
function getLogs() {
return driver.manage().logs().get('browser');
}
yield getCatalogPage();
for (let i = yield getProductsNumber(); i>4; i--){
yield openProduct(i);
let currentLogs = yield getLogs();
expect(currentLogs.length).to.equal(0, ' В логах браузера содержатся сообщения, при открытии товара из строки ' + i);
yield getCatalogPage();
}
});
test.after(() => driver.quit());
});