-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathparallel.js
47 lines (42 loc) · 1.31 KB
/
parallel.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
const { Builder, By, Key, until } = require('selenium-webdriver');
const http = require('http');
const BROWSERSTACK_USERNAME = process.env.BROWSERSTACK_USERNAME || 'BROWSERSTACK_USERNAME';
const BROWSERSTACK_ACCESS_KEY = process.env.BROWSERSTACK_ACCESS_KEY || 'BROWSERSTACK_ACCESS_KEY';
let HttpAgent = new http.Agent({
keepAlive: true,
});
let capabilities = [
{
browserName: 'Firefox',
name: 'Firefox Test',
os: 'Windows',
build: 'Test Build 01',
project: 'My Awesome App',
'browserstack.debug': true
},
{
browserName: 'Chrome',
name: 'Chrome Test',
os: 'Windows',
build: 'Test Build 01',
project: 'My Awesome App',
'browserstack.debug': true
}
]
for (let index in capabilities) {
let driver = new Builder()
.usingHttpAgent(HttpAgent)
.withCapabilities(capabilities[index])
.usingServer(`http://${BROWSERSTACK_USERNAME}:${BROWSERSTACK_ACCESS_KEY}@hub.browserstack.com/wd/hub`)
.build();
driver.get('http://www.google.com/ncr').then(() => {
driver.findElement(By.name('q')).then((element) => {
element.sendKeys('BrowserStack', Key.RETURN).then(() => {
driver.wait(until.titleContains('BrowserStack')).then(() => driver.getTitle().then((title) => {
console.log(title);
driver.quit();
}));
})
});
});
}