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('Signup')).click(); await driver.wait(until.urlIs(process.env.site_url + "/signup")); await driver.wait(until.elementLocated(By.name('User'), 5000)) await driver.findElement(By.name('Email')) .sendKeys(process.env.email); await driver.findElement(By.name('User')) .sendKeys(process.env.user) await driver.findElement(By.name('Password')) .sendKeys(process.env.password) await driver.findElement(By.name('PasswordRep')) .sendKeys(process.env.password) await driver.findElement(By.name('Signup')).click(); 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();