Internet Explorer Browser Not Opening URL when Running through Windows Task Sheduler

87 Views Asked by At

I am facing an issue when I am running my C# Selenium Code to Open a web page. It is a simple program to open a webpage in IE Browser. The code is perfectly working in VS. I have Scheduled as task using Windows Task Scheduler. It is opening the webpage with local host URL but not the URL I am expected to navigate(for eg: www.google.com). After 60 seconds, I am getting error HTTP request to remote web driver server for URL http://localhost:/session time out after 60 seconds.

InternetExplorerOptions Options = new InternetExplorerOptions();
Options.AttachToEdgeChrome = true;
IWebDriver Driver = new InternetExplorerDriver(Options); //This is the line failing.

Could you please guide me what's wrong?

I am expecting the Windows Task Scheduler - Task should open and load URL Expected.

2

There are 2 best solutions below

1
Bhairu On

Please try with this.

 ChromeOptions options = new ChromeOptions();
    Proxy proxy = new Proxy();
    proxy.Kind = ProxyKind.Manual;
    proxy.IsAutoDetect = false;
    proxy.SslProxy = "<HOST:PORT>";
    options.Proxy = proxy;
    options.AddArgument("ignore-certificate-errors");
    IWebDriver driver = new ChromeDriver(options);
    driver.Navigate().GoToUrl("https://www.selenium.dev/");
2
Greg Burghardt On

An answer to How to Set capability for IE browser to run in Headless mode mentions that running Internet Explorer in headless mode is not an option. That would have been my first suggestion, but that does not appear to work in IE.

When configuring the scheduled task, try check marking "Run only when user is logged in" under the "General" tab. This at least ensures you have an active desktop session so the GUI can be spawned. The downside is you will likely see a browser window open. The other big downside is the scheduled task will not run when you are not logged in.

If you want a headless Internet Explorer session that runs when you are logged out, then you are out of luck. No can do. Hard stop.

Unfortunately you don't have a lot of options here. You are using unsupported software. There does not appear to be a way to accomplish what you want.