const { Builder, By, Key, until } = require('selenium-webdriver'); const chrome = require('selenium-webdriver/chrome'); const assert = require('assert'); async function validLogin() { const driver = await new Builder().forBrowser('chrome') .setChromeOptions(new chrome.Options() .addArguments('--headless') .addArguments('--no-sandbox') .addArguments('--disable-gpu') ) .build(); try { await driver.get(process.env.site_url); await driver.findElement(By.name('User')) .sendKeys('info@lufthansa.com'); await driver.findElement(By.name('Password')) .sendKeys('password1234'); await driver.findElement(By.name('Login')).click(); let title = await driver.getTitle(); assert.equal("Airport browser", title); await driver.wait(until.elementLocated(By.xpath("//h2[text()='Flights']", 5000))) let actualUrl = process.env.site_url + "/home?page=1"; let expectedUrl = await driver.getCurrentUrl(); assert.equal(actualUrl, expectedUrl); driver.quit(); } catch (err) { console.error(err); process.exitCode = 1; driver.quit(); } } validLogin();