-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathdebugExample1.js
76 lines (65 loc) · 2.23 KB
/
debugExample1.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
// debugExample1.js
//
// This is a simple test script that does the following:
// open a website
// validate title
// clicks on "Item 3" -> google
// waits for google.com to load
//
// This example shows several methods how to debug using:
// console.log()
// debug()
// getText()
// To Run:
// $ mocha debugExample1.js
// Updated to support version 4 of webdriverio
// required libraries
var webdriverio = require('webdriverio'),
should = require('should');
// a test script block or suite
describe('Link Test for Web Driver IO - Tutorial Test Page Website', function() {
// set timeout to 60 seconds
this.timeout(60000);
var driver = {};
// hook to run before tests
before( function () {
// load the driver for browser
driver = webdriverio.remote({ desiredCapabilities: {browserName: 'firefox'} });
return driver.init();
});
// a test spec - "specification"
it('should be load correct page and title', function () {
// load page, then call function()
return driver
//.url('http://www.tlkeith.com/WebDriverIOTutorialTest.html')
.url('file:///Users/tkeith/Testing/Tutorial/HTML/WebDriverIOTutorialTest.html')
// get title, then pass title to function()
.getTitle().then(function (title) {
// verify title
(title).should.be.equal("Web Driver IO - Tutorial Test Page");
});
});
// Click on the Item 3 from list
it('should click on Item 3 from list', function () {
// use getText() to verify the xpath is correct for the element
return driver
.getText("//ul[@id='mylist']/li[3]/div/div/a").then(function (link) {
// use console.log() to output information
console.log('Link found: ' + link);
(link).should.equal("Item 3");
})
// use debug() to stop action to see what is happening on the browser - press enter to continue
.debug()
.click("//ul[@id='mylist']/li[3]/div/div/a").then (function () {
console.log('Link clicked');
})
// wait for google search form to appear
.waitForVisible("#tsf", 20000).then(function (e) {
console.log('Search Results Found');
});
});
// a "hook" to run after all tests in this block
after(function() {
return driver.end();
});
});