Protractor fails to detect displayed native alerts

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();

Answer №1

This particular issue arises from the "External Protocol Request" dialog, which is not a standard alert but rather a browser/system dialog that cannot be manipulated through Protractor or Selenium commands. For more information on how to handle this in Chrome, check out these forum threads:

  • Bypassing the "External protocol request" popup in Selenium automation
  • Is there a Chrome switch to suppress 'external protocol request'?

Dealing with this issue in Firefox may be easier. You can follow these steps:

  • Manually open Firefox, click the "call" button, and set your default application for external protocol requests
  • Navigate to "Help"->"Troubleshooting information" and access the profile folder location
  • Copy the profile directory path and utilize it to launch Protractor with Firefox using this specific profile

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Having difficulties in Vue while attempting to access a particular row

I encountered an error message stating Uncaught TypeError: snapShotChnaged.forEach is not a function. My goal is to retrieve specific row data, which is why I am utilizing the doc method. retrieveSpecificDonation() { firestore .collection('d ...

Having trouble running a form due to the inclusion of JavaScript within PHP code

My PHP code includes a form that connects to a database, but when I add JavaScript to the same file, the form does not execute properly. (I have omitted the insert code here.) echo '<form action="$_SERVER["REQUEST_URI"];" method="POST">'; ...

When an assertion fails with Protractor and Cucumber, the test execution comes to an abrupt halt

Cucumber Test Scenario @login Scenario: Test signin link Given the user goes to "example.com" When the user clicks on login button Then the current page is the login page Hi, I am facing an issue where my test execution abruptly stops when a chai/&apos ...

Execute a batch operation or transaction within a Cloud Firestore onCreate trigger

Imagine a scenario where I have a collection of vendor documents in firestore: vendors : { vendor1: { id: "vendor1", name: "John", shopId: "shop1" }, vendor2: { id: "vendor2", name: "Mary", shopId: "shop2" } } Additionally ...

incapable of modifying the contents of an array

Struggling with a JavaScript issue (not angular related, but within an Angular context) for hours without any success. I've condensed the content into shorter paragraphs and reassigned the subcontent back to the array's content property, but the ...

What is the most effective way to transfer data from a Django view to JavaScript for execution on a webpage?

I recently learned that it may not be the best practice to retrieve data from a Django view and utilize that information within the Javascript loaded on the page. For instance, if I am developing an application that requires additional data to be fetched ...

Use the onclick event to submit a form, ensuring that it can only be submitted once

For a form, I am configuring the action and triggering submission using the onclick event of a div: <div class="action_button" onclick="document.forms['test'].action='url/to/action';document.forms['test'].submit()"> < ...

What could be causing my tab code to not function flawlessly?

I am attempting to implement a tab concept on my website. For example, the tab names are Monday...Tue.. up to Sunday. Each tab contains an image file based on the days (size 460*620). When I run my page, it shows all images, but what I need is for the imag ...

Is there a way for me to locate and access the web element associated with the "Canvas Id" on an HTML page?

Currently, I am utilizing selenium3 webdriver to automate an html page that contains numerous click buttons. However, I am encountering difficulty accessing these buttons as the entire page is displayed as a canvas element. At this point, I am stuck and wo ...

Using radio buttons and a price slider, a unique jQuery filter for products can be

I have successfully implemented basic functionality to filter products based on price (slider) and radio boxes. However, the current filter system uses OR logic, but I need it to use AND instead. For instance, I want to find a product that is from Brand1, ...

Efficient method for handling numerous AJAX requests

I have a web application that currently makes 14-15 AJAX calls to various APIs. The issue is that the combined time it takes for all the AJAX calls to complete is significantly longer than when I individually type each API's URL into the browser. Cur ...

The ngClass directive does not seem to be functioning properly when utilizing multiple conditions

Trying to apply [ngClass] under different conditions. Here is what I have: condition [ngClass]="{'validator':lang.VideoURL!=null, 'labeltitle': lang.VideoURL==null}" However, when the value of lang.VideoURL is null, the labeltitle cl ...

How come an <a> tag is nabbing mouse clicks from a <canvas> element?

I have been experimenting with creating a 3D piano using three.js. Here is a snippet of the code I am currently working on: let renderer, camera, scene, light, keys, selectedKey; init(); render(); function init() { // Code for initializing renderer, ...

Ensuring that all checkboxes have been selected

I have 5 checkboxes all with the attribute name set as relative-view. To confirm that all of them are checked, I know how to verify the first and last one: expect(element.find('input[name="relative-view"]').first().prop("checked")).toBe(true); ...

What is the best method to display a tooltip for a disabled radio button within a set of radio buttons?

Is there a way to disable a specific radio button based on a condition and display a tooltip only for that disabled button? https://i.stack.imgur.com/niZK1.png import {Tooltip} from '@mui/material'; <Tooltip titl ...

Exchange of arrays between basic classes is made possible with ExtJS

I have two subclasses that inherit from a parent class. Class1 inherits from BaseClass Class2 inherits from BaseClass I create instances of both classes. When I display the array content of Class2, I see the contents of Class1 as well. http://jsfiddle ...

What is the method for extracting the href attribute from an <a class using Python Selenium?

I am attempting to extract a href from a webpage using selenium. When I utilize the browser console with this javascript command, I successfully get the desired href: document.getElementsByClassName('item-panel__title')[0].getAttribute('href ...

Utilizing 'document.execCommand' for handling 'delete' key events in AngularJS

Here is a demo plunkr link that I have created to demonstrate the issue. I am looking to implement the strikeThrough command whenever there is a delete operation. For instance: If the user selects "Text" and presses the delete or backspace key, it should ...

What is the process for a browser to load JavaScript resources?

I decided to do some research on how browsers load resources like CSS, JS, Images, HTML, etc. After creating a prototype code based on my findings, I became a bit confused during testing. Below is the Plnkr code where I included a <script> tag to int ...

Any suggestions on how to simulate data for the this.getResults$.subscribe method in Angular when testing unit cases?

showMessage(){ this.retrievedData$.subscribe(result =>{ if(result !== undefined && result !== null){ this.message = result.content; }else{ this.message="No Data"; }); } What is the best way to create mock data for testing the above method in ...