-
Notifications
You must be signed in to change notification settings - Fork 4
/
sampleSpec.js
55 lines (46 loc) · 1.51 KB
/
sampleSpec.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
var webdriver = require('selenium-webdriver');
var SauceLabs = require("saucelabs").default;
var username = process.env.SAUCE_USERNAME;
var accessKey = process.env.SAUCE_ACCESS_KEY;
var saucelabs = new SauceLabs({
username: username,
password: accessKey
});
var customReporter = require("./helpers");
jasmine.DEFAULT_TIMEOUT_INTERVAL = 100000;
describe('basic test', function () {
beforeAll(function () {
jasmine.getEnv().addReporter(customReporter)
})
beforeEach(async function () {
var browser = process.env.BROWSER,
version = process.env.VERSION,
platform = process.env.PLATFORM,
server = "http://" + username + ":" + accessKey +
"@ondemand.saucelabs.com:80/wd/hub";
driver = await new webdriver.Builder().
withCapabilities({
'browserName': browser,
'platform': platform,
'version': version,
'username': username,
'accessKey': accessKey,
'name': jasmine.currentTest.title
}).
usingServer(server).
build();
driver.sessionID = await driver.getSession();
});
afterEach(async function () {
var results = jasmine.currentTest.failedExpectations;
await saucelabs.updateJob(username, driver.sessionID.id_, {
passed: results.length === 0
});
await driver.quit();
});
it('should be on correct page', async function (done) {
await driver.get('https://saucelabs.com/test/guinea-pig');
expect(await driver.getTitle()).toBe('I am a page title - Sauce Labs');
done();
});
});