-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathhooks.js
More file actions
36 lines (30 loc) · 961 Bytes
/
hooks.js
File metadata and controls
36 lines (30 loc) · 961 Bytes
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
'use strict';
const { Builder, Capabilities } = require("selenium-webdriver");
const { Before, After, BeforeAll, AfterAll } = require("@cucumber/cucumber");
const assert = require('assert');
var createBrowserStackSession = function(){
return new Builder().
usingServer('http://localhost:4444/wd/hub').
withCapabilities(Capabilities.chrome()).
build();
}
let globalDriver;
BeforeAll(async function () {
globalDriver = createBrowserStackSession();
await globalDriver.get('https://bstackdemo.com/');
const title = await globalDriver.getTitle();
assert.match(title, /StackDemo/i, 'Title does not match /StackDemo/i');
});
AfterAll(async function(){
if (globalDriver) {
await globalDriver.quit();
}
});
// Optionally, make globalDriver available in steps via World
const { setWorldConstructor } = require('@cucumber/cucumber');
class CustomWorld {
get driver() {
return globalDriver;
}
}
setWorldConstructor(CustomWorld);