Microsoft Edge Browser Alerts do not get handled when using the Microsoft Edge WebDriver

Issue #16448300 • Assigned to James M.

Details

Author
Franco D.
Created
Mar 19, 2018
Privacy
This issue is public.
Found in
  • Microsoft Edge
Reports
Reported by 1 person

Sign in to watch or report this issue.

Steps to reproduce

I am using Windows 10 Build 10586. I have installed Microsoft Edge browser Release 10586

Microsoft Edge Browser Alerts are not getting handled when using the Microsoft Edge WebDriver. The alert will stay on the screen and the OK button never gets clicked by WebDriver

Here are 2 sample programs that I am using:

Program 1:

package trainingSeleniumAutomation;

import java.util.Collections;

import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.testng.annotations.Test;

public class DemoAlertEdge {

@Test
public void handleAlert()
 {
  
    //Initiate Browser
            System.setProperty("webdriver.edge.driver", "C:\\MicrosoftEdge\\MicrosoftWebDriver.exe");
    
    WebDriver driver = new EdgeDriver();
    driver.manage().window().maximize();
    driver.get("http://www.ksrtc.in/oprs-web/"); 
    
    
    driver.findElement(By.xpath("//*[@id='searchBtn']")).click();
    
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    
    Alert alt = driver.switchTo().alert();  //indirect approach
    
    alt.accept();
    //alt.dismiss();
            
 }

}

Program 2 :

package trainingSeleniumAutomation;

import java.util.Collections;

import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.testng.Assert;
import org.testng.annotations.Test;

public class DemoAlertEdge2 {

@Test
public void handleAlert() throws Throwable
 {
  
    System.setProperty("webdriver.edge.driver", "C:\\MicrosoftEdge\\MicrosoftWebDriver.exe");
    
    WebDriver driver = new EdgeDriver();
    driver.manage().window().maximize();
    driver.get("http://www.ksrtc.in/oprs-web/"); 
    
    Thread.sleep(5000);
    
    driver.findElement(By.xpath("//*[@id='searchBtn']")).click();
    
    try {
        Thread.sleep(5000);
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    
    String actual_msg = driver.switchTo().alert().getText();    
    
    System.out.println("Alert message is "+actual_msg);
    
    driver.switchTo().alert().accept();  //direct approach
    //driver.switchTo().alert().dismiss();
    
    String expected_msg = "Please select start place.";
    
    Assert.assertEquals(actual_msg, expected_msg);
    
    driver.quit();
 }

}

Attachments

Comments and activity

  • Microsoft Edge Team

    Changed Assigned To to “James M.”

  • Hello,

    Thank you for providing this information about the issue. We have made many improvements since 10586 and ask that you please test this behavior in our latest public stable build 16299.

    Best Wishes,
    The MS Edge Team

You need to sign in to your Microsoft account to add a comment.

Sign in