Attempting to manage a native opened alert, but encountering an issue with protractor not recognizing the alert and displaying an error in the console:
1) Test cases pull - LiveSite - Call Message: NoSuchAlertError: no alert open (Session info: chrome=51.0.2704.103) Command duration or timeout: 9 milliseconds Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50' System info: host: 'vCitaQA', ip: '10.0.0.5', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_65' Driver info: org.openqa.selenium.chrome.ChromeDriver Stacktrace: NoSuchAlertError: no alert open (Session info: chrome=51.0.2704.103) at new bot.Error (C:\automation\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\error.js:113:18) ...
Tried using the following code snippet:
describe('vCita Production - Livesite (client side)', function() {
var EC = protractor.ExpectedConditions;
var callBtn = $$('div.action-content.layout-align-center.layout-column.flex').get(1);
beforeEach(function() {
browser.ignoreSynchronization = true;
});
afterEach(function() {
browser.ignoreSynchronization = false;
});
it('click on call button', function() {
callBtn.click().then(function(){
browser.driver.sleep(2000);
browser.driver.switchTo().alert().dismiss();
});
});
});
Also implemented the below code snippet which functions properly, but does not enter the "(alert)" if statement:
browser.getAllWindowHandles().then(function (handles) {
browser.switchTo().window(handles[handles.length - 1]);
var alertDialog = browser.switchTo().alert().thenCatch(function (e) {
if (e.code !== 27) { throw e; }
}).then(function (alert) {
if (alert) {
expect(alertDialog.getText()).toEqual("External Protocol Request");
return alert.dismiss();
}
callBtn.click();