I´ve been developing on Galen for a while now but I´ve encountered a wall when handling alerts on the tests. In this case, after a couple of steps on the test, there´s an alert that pops-up and it requires authentication to proceed with the test.
I´ve already tried using driver.switchTo().alert() but this doesn´t work at all. The only way I´ve been able to go around it in another projects using the Java function ((HasAuthentication) webDriver).register(() -> new UsernameAndPassword("admin", "admin"));
. Now, as far as I know this only works in Java and I haven´t found any alternative for JS on Galen.
This is my Galen test and I´ve commented on the steps where the alert appears.
The alert in question: here
Thanks!
// First, the pages document is loaded so the page elements can be used on the test
load("Pages\\ACloginPages.js");
// In this function, which is done before the test, the web page is loaded and the driver is created
beforeTest(function () {
driver = createDriver("***", "2030x1140");
session.put("driver", driver);
});
//Here the different viewports are declared and later used on the test
var devices = {
mobile:{
deviceName:"mobile",
tags:["mobile"],
size: "500x844"
},
desktop:{
deviceName:"desktop",
tags:["desktop"],
size:"1920x1080"
},
tablet:{
deviceName:"tablet",
tags:["tablet"],
size:"820x1180"
}
};
// On the test function, the web driver is executed and it navigates to the beta web page before
// Executing the UI test, note that the viewports declared above are used here on the test.
forAll(devices, function(){
test("My trips page on ${deviceName} final", function(device){
var driver = session.get("driver");
var legacyPage = new LegacyPage(driver);
legacyPage.waitForIt("200s");
legacyPage.betaButton.click();
var loginPage = new LoginPage(driver);
loginPage.waitForIt("200s");
** ALERT APPEARS HERE **
loginPage.loginUser.typeText("[email protected]");
loginPage.loginPassword.typeText("Abc@123456");
loginPage.loginSubmit.click();
GalenPages.sleep(15000);
var flightsTab = new FlightsTab(driver);
flightsTab.tripType.waitForIt("200s");
** ALERT APPEARS HERE **
flightsTab.bookPoints.click();
flightsTab.tripType.click();
GalenPages.sleep(5000);
flightsTab.multicitySelect.click();
flightsTab.tripClose.click();
GalenPages.sleep(5000);
flightsTab.add1Stopover.click();
flightsTab.add2Stopover.click();
GalenPages.sleep(3000);
resize(driver, device.size);
checkLayout(driver,"Gspecs\\HP-3444.gspec",device.tags);
});
});
//After the test is donde the driver closes
afterTest(function() {
var driver = session.get("driver");
driver.quit();
});
I´ve tried using chromedriver alert blocking capabilities and the switchTo().alert() selenium method but neither of those works.