I started having issues with Selenium being able to detect elements on a page. Up until yesterday this code worked just fine, but something seems to have changed causing the WebDriver to timeout versus finding the Element. I tried modifying the code to point to
and search for the Name("q"), but it's not picking it up.
I'm using Internet Explorer 11 for this. Has anyone else come across this before?
It's worth noting that I rolled back to the previous drivers in case an updated driver caused the problems (even though there hasn't been one published since last month), but the results remain the same.
I set the timeout for 10 seconds to give the page a chance to fully load, otherwise I would throw an exception.
namespace SeleniumTest
{
class Program
{
static void Main(string[] args)
{
var _ieOptions = new InternetExplorerOptions();
_ieOptions.IgnoreZoomLevel = true;
var _driver = new InternetExplorerDriver(_ieOptions);
//var __driver = new ChromeDriver();
var _wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(10));
_wait.Until(ExpectedConditions.ElementExists(By.Name("UserId")));
_driver.FindElement(By.Name("UserId")).SendKeys("Google");
}
}
}
Here's the error.
OpenQA.Selenium.WebDriverTimeoutException was unhandled
Message=Timed out after 10 seconds
Source=WebDriver.Support
StackTrace:
at OpenQA.Selenium.Support.UI.DefaultWait`1.ThrowTimeoutException(String exceptionMessage, Exception lastException)
at OpenQA.Selenium.Support.UI.DefaultWait`1.Until[TResult](Func`2 condition)
at SeleniumTest.Program.Main(String[] args) in C:\Users\justin.oconnor\OneDrive\Visual Studio\Projects\SeleniumTest\SeleniumTest\Program.cs:line 28
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
Message=Unable to find element on closed window
Source=WebDriver
StackTrace:
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism, String value)
at OpenQA.Selenium.Support.UI.DefaultWait`1.Until[TResult](Func`2 condition)
InnerException: