forked from adelamr18/seleniumTest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
29 lines (25 loc) · 1.15 KB
/
index.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
const { Builder, By, ChromeOptions } = require("selenium-webdriver");
var assert = require("assert");
// To prevenet the need to install chromedriver on the agent or doing any PATH handling
const chrome = require("selenium-webdriver/chrome");
const chromedriver = require("chromedriver");
chrome.setDefaultService(new chrome.ServiceBuilder(chromedriver.path).build());
async function checkIfTitleExistsAndNavigate() {
// Use headless chrome for automations
const options = new chrome.Options();
options.addArguments("--headless");
options.addArguments("--no-sandbox");
const driver = await new Builder().forBrowser("chrome").setChromeOptions(options).build();
await driver.get("https://phptravels.com/demo");
const headerText = await (await driver.findElement(By.id("header-title"))).getAttribute("innerHTML");
assert.equal("Application Test Drive", headerText);
await pressOnIntegrationsTab(driver);
driver.quit();
}
async function pressOnIntegrationsTab(driver) {
await (await driver.findElement(By.className("clearfix"))).click();
}
checkIfTitleExistsAndNavigate().catch(err=>{
console.error(err);
process.exit(1);
});