简体   繁体   中英

Selenium can't handle new window with edge IE mode C#

For an automation project I have to use selenium webdriver with edge. Unfortunately the site is under IE kernel. So I start edge in IE mode everything works fine. But when the controller needs to detect a new window with windowHandle, it does not detect anything new even with a wait. Is it possible to make the switch work in IE mode?

PS : As I use an IE driver I can by changing a few lines start IE. When I run IE the window change is done. When I run Edge with the options I don't detect anything. So everything works fine with the IE browser, the problem only comes from edge and the IE mod.

I am using an IE driver with capabilities like this:

   var ieService = InternetExplorerDriverService.CreateDefaultService(dir, driver); 
    var ieOptions = new InternetExplorerOptions{}; 
    ieOptions.AddAdditionalCapability("ie.edgechromium", true); 
    ieOptions.AddAdditionalCapability("ie.edgepath", "{path to msedge.exe}"); 

    var webdriver = new InternetExplorerDriver(ieService, ieOptions, TimeSpan.FromSeconds(30)); 
driver.FindElement(By.Id("button")).Click(); 
 
Thread.Sleep(2000); 

string popupHandle = string.Empty; 
ReadOnlyCollection<string> windowHandles = driver.WindowHandles;  

foreach (string handle in windowHandles)  
{  
    if (handle != existingWindowHandle)  
    {  
         popupHandle = handle;
         break;  
    }  
}  
driver.SwitchTo().Window(popupHandle); 

Now it is solved. You can download latest Selenium version 4.0 and start scripting for Edge in IE Mode. You can also follow the issue ticket in github in the following link MS Edge in IE Mode

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM