-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathexample_test.js
34 lines (29 loc) · 1.27 KB
/
example_test.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
var util = require('util'),
webdriver = require('selenium-webdriver'),
chrome = require('selenium-webdriver/chrome'),
retry = require('./index.js');
// Assumes that there is a chromedriver binary in the same directory.
var driver = chrome.createDriver(
new webdriver.Capabilities({'browserName': 'chrome'}),
new chrome.ServiceBuilder('./chromedriver').build());
driver.get('http://juliemr.github.io/webdriverjs-retry/');
retry.run(function() {
// Note that everything in here will be retried - including the
// first click.
driver.findElement(webdriver.By.id('showmessage')).click();
// This would throw an error without waiting because the message
// is hidden for 3 seconds.
driver.findElement(webdriver.By.id('message')).click();
}, 5000).then(function() {
// run returns a promise which resolves when all the retrying is done
// If the retry fails (either it times out or the error is not in the ignore
// list) the promise will be rejected.
});
// 7 is the error code for element not found.
retry.ignoring(7).run(function() {
driver.findElement(webdriver.By.id('creatediv')).click();
// This would throw an error because the div does not appear for
// 3 seconds.
driver.findElement(webdriver.By.id('inserted')).getText();
}, 5000);
driver.quit();