Why is Selenium hung when accessing the URL?

I am a beginner of Selenium.Now I have a website must access by IE (Chrome or Edge do not support it at all).

As Microsoft remove IE in the newest Windows, the website can only access by Compatibility (IE) Mode in Edge.

Here is my code:

 var options = new InternetExplorerOptions
 {
     IgnoreZoomLevel = true, 
     IntroduceInstabilityByIgnoringProtectedModeSettings = true,
     EnsureCleanSession = true,
     PageLoadStrategy = PageLoadStrategy.Normal
 };
 
 IWebDriver driver = new InternetExplorerDriver($@"{AppDomain.CurrentDomain.BaseDirectory}IEDriverServer.exe", options);
 driver.Manage().Window.Maximize();
 driver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(60);
 driver.Navigate().GoToUrl("https://cced.com/cced.aspx");

 Debug.WriteLine(driver. Title);

After the program ran, it opens Edge browser and accesses the homepage of the website by IE mode successfully.

However, even I add a breakpoint to the line Debug.WriteLine(driver. Title); it never runs.

After 1 minute, it reports an error like this:

OpenQA.Selenium.WebDriverException
  HResult=0x80131500
  Message=The HTTP request to the remote WebDriver server for URL http://localhost:9324/session/700c0df3-fcf5-459e-a9d9-0487cfd42d15/url timed out after 60 seconds.
  Source=WebDriver
  StackTrace:
   at OpenQA.Selenium.Remote.HttpCommandExecutor.<ExecuteAsync>d__34.MoveNext()
   at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.<ExecuteAsync>d__10.MoveNext()
   at OpenQA.Selenium.WebDriver.<ExecuteAsync>d__63.MoveNext()
   at OpenQA.Selenium.Navigator.<GoToUrlAsync>d__7.MoveNext()
   at OpenQA.Selenium.Navigator.<>c__DisplayClass6_0.<<GoToUrl>b__0>d.MoveNext()
   at OpenQA.Selenium.Navigator.GoToUrl(String url)
   at ERPDownload.Form1.Form1_Load(Object sender, EventArgs e) in D:ProjectTestTestForm1.cs:line 28
   at System.Windows.Forms.Form.OnLoad(EventArgs e)
   at System.Windows.Forms.Control.CreateControl(Boolean ignoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(HWND hWnd, MessageId msg, WPARAM wparam, LPARAM lparam)

Inner Exception 1:
TaskCanceledException: The request was canceled due to the configured HttpClient.Timeout of 60 seconds elapsing.

Inner Exception 2:
TimeoutException: The operation was canceled.

Inner Exception 3:
TaskCanceledException: The operation was canceled.

Inner Exception 4:
IOException: Unable to read data from the transport connection: The I/O operation has been aborted because of either a thread exit or an application request.

Inner Exception 5:
SocketException: The I/O operation has been aborted because of either a thread exit or an application request.

What’s wrong with it?

The right way to automate IE mode is defining InternetExplorerOptions with additional properties that point to the Edge browser. You need to set ieOptions.AttachToEdgeChrome property to true, and ieOptions.EdgeExecutablePath to the path of the Microsoft Edge executable.

Please refer to the following steps:

  1. Download IEDriver and make sure that the version of IEDriver that you download is 4.0.0.0 or greater.
  2. Meet the requirements for Selenium’s required configuration.
  3. Place the IEDriver executable in your PATH.
  4. Sample code to automate IE mode:
    using System;
    using OpenQA.Selenium;
    using OpenQA.Selenium.IE;
    
    namespace IEDriverSample
    {
        class Program
        {
            static void Main(string[] args)
            {
                var ieOptions = new InternetExplorerOptions();
                ieOptions.AttachToEdgeChrome = true;
                //change the path accordingly
                ieOptions.EdgeExecutablePath = "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe";
    
                var driver = new InternetExplorerDriver(ieOptions);
                driver.Url = "http://cced.com/cced.aspx";
    
                driver.Quit();
            }
        }
    }

You can also refer to this official doc for detailed information: Use Internet Explorer Driver to automate IE mode in Microsoft Edge.


Update:

  1. If Protected Mode doesn’t exist in IE setting, you need to check it in registry. Please check HKCUSoftwareMicrosoftWindowsCurrentVersionInternet SettingsZones in registry, under Zones is a subkey for each zone:
  • 1 (Intranet zone)
  • 2 (Trusted Sites zone)
  • 3 (Internet zone)
  • 4 (Restricted Sites zone)

Under each numerically-named key, you can check or create a REG_DWORD value named 2500 to control Protected Mode for each zone. Setting that value to 0 enables Protected Mode; a setting of 3 disables it.

  1. It’s recommended to download and use 32-bit IEDriver. In my experience, there might be some issues when using 64-bit version.

4

I can suggest trying other ways to debug this code as it seams that it’s running locally and some things can go wrong in the enviroment configuration of the process.

first of all, check if the process running in the host http://localhost:9324/session/700c0df3-fcf5-459e-a9d9-0487cfd42d15/url is definitely available.

If so, try to increase the maxTimeout from your service’s http requests.

If both approaches do not work, add an try/catch exception for this whole block and try to understand more specifically what is going wrong to. If you figure out another exception, post it here.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật