-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathtest.js
62 lines (52 loc) · 1.84 KB
/
test.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
const webdriver = require('selenium-webdriver');
const By = webdriver.By;
// Setup LambdaTest authentication and grid URL
const USERNAME = process.env.LT_USERNAME;
const KEY = process.env.LT_ACCESS_KEY;
const GRID_HOST = 'hub.lambdatest.com/wd/hub';
async function pdfWebTest() {
// Setup Input capabilities, Know more about LamdbdaTest Capabilities: https://www.lambdatest.com/capabilities-generator/
const capabilities = {
"browserName": "Chrome",
// "browserVersion": "latest", #Uncomment to Specify Browser Version
"LT:Options": {
name: 'NodeJS Get Set Go', // name of the test
build: 'NodeJS Loves LambdaTest', // name of the build
"project": "Build-With-LambdaTtest",
"w3c": true,
"plugin": "NodeJS",
"customData":
{
_id: "5f46aaa69adf77cfe2bb4fd6",
index: "0",
guid: "9451b204-12f0-4177-8fe9-fb019b3e4bf3",
isActive: "False",
picture: "http://placehold.it/32x32",
},
}
};
const gridUrl = 'https://' + USERNAME + ':' + KEY + '@' + GRID_HOST;
// Setup and build selenium driver object
const driver = new webdriver.Builder()
.usingServer(gridUrl)
.withCapabilities(capabilities)
.build();
try {
await driver.get('https://pdfstandalone.com/#/');
// Get the elements with the specified XPath
const elements = await driver.findElements(By.xpath('//span[@title="Language"]'));
// Click on the first element (index 0)
if (elements.length > 0) {
await elements[0].click();
console.log("Successfully clicked first list item.");
}
driver.executeScript('lambda-status=passed');
// Close the browser
await driver.quit();
} catch (err) {
console.log("test failed with reason " + err);
driver.executeScript('lambda-status=failed');
driver.quit();
}
}
pdfWebTest();