0

Now Im using selenium version 4.8.1

With the following Code:

var ieOptions = new InternetExplorerOptions { };

ieOptions.AttachToEdgeChrome = true;

ieOptions.IntroduceInstabilityByIgnoringProtectedModeSettings= true;

WebDriver driver = new InternetExplorerDriver(ieOptions);

driver.Navigate().GoToUrl("https://bing.com");

driver.FindElement(By.Id("sb_form_q")).SendKeys("Hello world");

driver.FindElement(By.Id("sb_form")).Submit();

When I run the code, the program stops and timeouts after 60 seconds at the line

driver.Navigate().GoToUrl("https://bing.com");

I have consulted a few ways and I got it working when I turned off protected mode in internet options. Is there a way for me to not have to turn off protected mode in internet options and still be able to run normally?

Akzy
  • 1,817
  • 1
  • 7
  • 19
Xia
  • 1
  • 3

1 Answers1

0

Normally, you don't have to turn off protected mode if you have already specified IntroduceInstabilityByIgnoringProtectedModeSettings = true. I failed to reproduce this issue with my IE Driver 4.8.1.0. It may have something to do with your IE Driver version (you've only said Selenium 4.8.1 but I'm not sure about your IE Driver version). You can try installing the latest version of IE Driver if you haven't.

Update

I've found that it seems to be a common issue because it has also been reported elsewhere after you shared this issue. Changing registry settings of protected mode could be one of the solutions. Another possible solution is to directly navigate to the target URL without waiting for redirection from localhost. You can try the following option:

ieOptions.InitialBrowserUrl = "https://bing.com";
Kendrick Li
  • 1,355
  • 1
  • 2
  • 10
  • I dont know why, but if I dont uncheck protected mode in internet options, I cant run anymore after "driver.Navigate().GoToUrl("https://bing.com");" and my IE driver and selenium are both latest version – Xia Mar 17 '23 at 09:54
  • So, you could only see the page got rendered but no "sendkeys" happened? Any error message? – Kendrick Li Mar 17 '23 at 09:58
  • Yeah. Dont have sendkey action. Error message will occur after 60s: OpenQA.Selenium.WebDriverException: 'The HTTP request to the remote WebDriver server for URL http://localhost:52091/session/162da605-7226-4516-be49-7d06425484b0/url timed out after 60 seconds.' – Xia Mar 17 '23 at 10:01
  • According to this error message, I think you can add a Sleep/[Wait](https://www.selenium.dev/documentation/webdriver/waits/)/[Timeout](https://www.selenium.dev/documentation/webdriver/drivers/options/#timeouts). Also, I've found a customized method to retry. Check [this thread](https://stackoverflow.com/questions/54522602/the-http-request-to-the-remote-webdriver-server-for-url-timed-out-after-60-s). – Kendrick Li Mar 20 '23 at 06:43
  • I tried sleep/wait/thread but to no avail. What is your method? I changed the parameters of Internet Options in the regitry and It worked. – Xia Mar 21 '23 at 02:31
  • Emm, I haven't added any of them because I couldn't reproduce this timeout error. Though they were supposed to work since it is a timeout error. So, is changing registry settings an acceptable solution for you? – Kendrick Li Mar 21 '23 at 03:08
  • Thank you for your contribution. I already have a workaround inside the registry to change protected mode. Its very effective. – Xia Mar 29 '23 at 02:38
  • @Xia You're welcome. Actually, I've found another possible solution for you. I've updated it in my answer. – Kendrick Li Mar 29 '23 at 02:45