That's it basically, when i run the app manually it runs fine, but when I run it with task scheduler it fails in the middle of application with the exception:
OpenQA.Selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"*[name ="start_year"]"}
The strange part is, the program mostly works with the scheduler, it calls a few webapi before it fails, loads appsettings.json values, but when it is scheduled on windows (I tried with a few windows server and reproducable with windows 10 home as well), when Selenium loaded a site and logged in, than fails to find a dom element every time.
I tried to run with highest privileges, tried setting the run wether user not logged in in scheduler, I set the value of my app folder in task scheduler Start in textbox, it seems like no changes in task scheduler settings helps.
I using IHostBuilder and dependency injection with latest 4.8.0 Selenium.Support and Selenium.WebDriver nuget packages.
I using implicitwait and the following chromeoptions:
var chromeOptions = new ChromeOptions
{
BinaryLocation = config["chromebinarypath"],
};
chromeOptions.AddArgument("--disable-extensions");// disabling extensions
chromeOptions.AddArgument("--disable-gpu");// applicable to windows os only
chromeOptions.AddArgument("--disable-dev-shm-usage");// overcome limited resource problems
chromeOptions.AddArgument("--no-sandbox");// Bypass OS security model
chromeOptions.AddArgument("--headless");// Bypass OS security model
_chromeDriver = new ChromeDriver(chromeOptions);
_chromeDriver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(180);
//Important, enables waiting for dom objects till they available for 10 seconds.
_chromeDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
Can someone point me to right direction?
Maybe it is some kind of Selenium bug? Maybe the issue is related to the used IHost, and I should just call the classes without dependecy injection?