-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
47 lines (41 loc) · 2.11 KB
/
app.js
File metadata and controls
47 lines (41 loc) · 2.11 KB
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 webdriver = require('selenium-webdriver');
async function runTestWithCaps (capabilities) {
let driver = new webdriver.Builder()
.usingServer('http://hub-cloud.browserstack.com/wd/hub')
.withCapabilities({
...capabilities,
...capabilities['browser'] && { browserName: capabilities['browser']} // Because NodeJS language binding requires browserName to be defined
})
.build();
await driver.get("https://www.amazon.in/ap/signin?openid.pape.max_auth_age=0&openid.return_to=https%3A%2F%2Fwww.amazon.in%2Fyour-account%3Fref_%3Dnav_ya_signin&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.assoc_handle=inflex&openid.mode=checkid_setup&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&");
console.log (await driver.getTitle());
await driver.wait(webdriver.until.elementLocated(webdriver.By.name("email")), 10000);
await driver.findElement(webdriver.By.name("email")).click();
console.log (await driver.getTitle());
let str = "Amazon Sign In";
if (driver.getTitle = str) {
await driver.executeScript(
'browserstack_executor: {"action": "setSessionStatus", "arguments": {"status":"passed","reason": "Product has been successfully added to the cart!"}}'
);
} else {
await driver.executeScript('browserstack_executor: {"action": "setSessionStatus", "arguments": {"status":"failed","reason": "Oops! my sample test failed"}}');
}
await driver.quit();
}
const capabilities1 = {
'bstack:options' : {
"os": "Windows",
"osVersion": "10",
"browserVersion": "109.0",
"buildName" : "browserstack-build-1",
"sessionName" : "Parallel test 1",
'browserName': 'chrome',
'build': process.env.BROWSERSTACK_BUILD_NAME,
'project': process.env.BROWSERSTACK_PROJECT_NAME,
'browserstack.local': 'true',
'browserstack.localIdentifier': process.env.BROWSERSTACK_LOCAL_IDENTIFIER,
'browserstack.user': process.env.BROWSERSTACK_USERNAME,
'browserstack.key': process.env.BROWSERSTACK_ACCESS_KEY
}
}
runTestWithCaps(capabilities1);