I have a very basic Selenium test for bing.com on Chrome using C# .NET Core 3.1. It goes like this
[TestMethod]
[TestCategory("Chrome")]
public void TheBingSearchTest2()
{
var appURL = "http://www.bing.com/";
driver.Navigate().GoToUrl(appURL);
driver.Manage().Window.Maximize();
driver.FindElement(By.Id("sb_form_q")).SendKeys("Azure Pipelines");
var koss = driver.FindElement(By.Id("sb_form_go"));
Console.WriteLine("found element {0}", koss.GetAttribute("outerHTML"));
koss.Click();
}
Problem is, I keep getting a exception for the last line (the click step)
Message: Test method SeleniumDemo.MySeleniumTests.TheBingSearchTest2 threw exception: OpenQA.Selenium.ElementNotInteractableException: element not interactable (Session info: chrome=105.0.5195.53)
Stack Trace: WebDriver.UnpackAndThrowOnError(Response errorResponse, String commandToExecute) WebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters) WebDriver.InternalExecute(String driverCommandToExecute, Dictionary`2 parameters) WebElement.Execute(String commandToExecute, Dictionary`2 parameters) WebElement.Click() MySeleniumTests.TheBingSearchTest2() line 59
The logged output is correct, it gives
found element <input id="sb_form_go" type="submit" aria-label="Search" name="search" value="" tabindex="0">
When doing good ol' javascript fiddling, when I get the element #sb_form_go, and invoke .checkVisiblity() it returns true. I can even do .click() on it and it works.
I tried adding wait time before the last line, converting the method to async and doing
await Task.Delay(10000);
doesn't work. I tried to do
var wait1 = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
wait1.Until(ExpectedConditions.ElementToBeClickable(By.Id("sb_form_go")));
but then the error becomes
OpenQA.Selenium.WebDriverTimeoutException: Timed out after 10 seconds
Which is weird coz I'm sure it IS visible
Any idea here? This is the code to replicate the problem (not my exact private code but so line numbers are different) https://github.com/koko983/SeleniumBingDemo