![](/img/trans.png)
[英]Selenium webdriver C# automation script not working in edge browser
[英]Selenium Automation fails if Browser Already Open (Edge Chromium/VB.NET/C#)
我正在使用下面的 VB.NET 代碼 op open Edge Chromium(在 IE 功能模式下)。 如果沒有打開現有的 Edge 窗口,它就可以工作,否則,它只會在現有窗口中打開另一個選項卡,並只顯示這是 WebDriver 服務器的初始啟動頁面。 什么也沒發生(見下面的截圖)
Dim ieService = InternetExplorerDriverService.CreateDefaultService(Environment.CurrentDirectory, "IEDriverServer.exe")
Dim ieOptions = New InternetExplorerOptions
ieOptions.IgnoreZoomLevel = True
ieOptions.AddAdditionalCapability("ie.edgechromium", True)
ieOptions.AddAdditionalCapability("ie.edgepath", "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe")
Dim driver = New InternetExplorerDriver(ieService, ieOptions, TimeSpan.FromSeconds(60))
driver.Navigate().GoToUrl("https://example.com")
一分鍾后,它在Dim driver = New InternetExplorerDriver(ieService, ieOptions, TimeSpan.FromSeconds(60))
行拋出以下異常
OpenQA.Selenium.WebDriverException: '對遠程 WebDriver 服務器的 HTTP 請求 URL http://localhost:52074/session 在 60 秒后超時。
有誰知道如何解決這個問題? (我不想先終止邊緣會話然后再開始,因為我希望現有的邊緣窗口保持不變)
在已經打開的 Edge 瀏覽器窗口中自動化 Edge-IE。 請按照以下步驟
System.Diagnostics.Process.Start(@"msedge.exe", "https://google.com/");
Thread.Sleep(1000);
var dir = "//path of your Edgedriver";
var driver = "IEDriverServer.exe";
if (!Directory.Exists(dir) || !File.Exists(Path.Combine(dir, driver))){
Console.WriteLine("Failed to find {0} in {1} folder.", dir, driver);}
var ieService = InternetExplorerDriverService.CreateDefaultService(dir, driver);
var ieOptions = new InternetExplorerOptions { };
ieOptions.AddAdditionalCapability("ie.edgechromium", true);
ieOptions.AddAdditionalCapability("ie.edgepath", @"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe");
InternetExplorerDriver webdriver = new InternetExplorerDriver(ieService, ieOptions, TimeSpan.FromMinutes(3));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.