C# SendKeys command is not working in full execution

463 views Asked by At

Sendkeys is entering the value for below search dropdown only in debug mode.It doesn't work in full run even after adding waits or clicking and entering the value. Using Javascript, I'm able to enter the value in full run but search results are not shown which is not allowing me to select the value from the list of search results. HTML code: code image

Code for sendkeys used: driver.FindElement(FirstDestination).SendKeys("italy");

Code for javascript used:

IJavaScriptExecutor jse = (IJavaScriptExecutor)driver;
jse.ExecuteScript("arguments[0].value='italy';", driver.FindElement(FirstDestination));

Tried to use Actions class as well but no luck. Any quick help with this issue is really appreciated. I'm using Selenium with C# and specflow on Windows 10

1

There are 1 answers

0
cruisepandey On BEST ANSWER

You can use WebDriverWait to send the keys like below:

IWebElement firstDestination = wait.Until(e => e.FindElement(By.Id("Travel-TripDetails-DestinationFlexdata--label")));
firstDestination.SendKeys("Italy");

there's no need to use IJavaScriptExecutor as WebDriverWait would suffice in this case.