Reputation: 71
Sometimes, when my testing sensor reach alarming level, app immediately overlay browser window with incident window, which i must confirm, and then my tests fail. How can i solve this, without turning off incidents window in app configuration?
Upvotes: 0
Views: 2005
Reputation: 71
Use accept method to press ok/submit button on the displayed popup.
browser.driver.switchTo().alert().accept();
Dismiss javascript popup:
browser.driver.switchTo().alert().dismiss();
Get the text of javascript popup:
browser.driver.switchTo().alert().getText();
Send Keys to javascript popup:
browser.driver.switchTo().alert().sendKeys("Value");
Handling child browser popup in protractor: (This code switches into child browser popup)
Child browser is popup having many web elements. Elements inside the popup can be inspected and elements can be identified by find element and any actions can be performed on those elements.
browser.getAllWindowHandles().then(function(handles) {
var count=handles.length;
var newWindow = handles[count-1];
browser.switchTo().window(newWindow);
});
Upvotes: 1
Reputation: 1110
You need to check if element is present and if is present to click it, some code similar to this:
static async clickIfPresent(target: ElementFinder) {
const isPresent = await target.isPresent();
if (isPresent) {
return this.click(target);
}
return;
}
Upvotes: 0