'C# SendKeys command is not working in full execution

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



Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 cruisepandey