-
Notifications
You must be signed in to change notification settings - Fork 15
/
index.js
29 lines (21 loc) · 984 Bytes
/
index.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
var $driver = require('selenium-webdriver');
var driver = new $driver.Builder().withCapabilities($driver.Capabilities.chrome()).build();
var $browser = driver;
$browser.waitForElement = function (locatorOrElement, timeoutMsOpt) {
return $browser.wait($driver.until.elementLocated(locatorOrElement), timeoutMsOpt || 5000, 'Timed-out waiting for element to be located using: ' + locatorOrElement);
};
$browser.waitForAndFindElement = function (locatorOrElement, timeoutMsOpt) {
return $browser.waitForElement(locatorOrElement, timeoutMsOpt)
.then(function (element) {
return $browser.wait($driver.until.elementIsVisible(element), timeoutMsOpt || 5000, 'Timed-out waiting for element to be visible using:' + locatorOrElement)
.then(function () {
return element;
});
});
};
global.$browser = $browser;
global.$driver = $driver;
module.exports = {
driver: $driver,
browser: $browser
};