1

I have been trying to automate a browser operation via selenium, google.com will be opened, but the text is not searched. The code used is:

IWebDriver driver = new ChromeDriver();
driver.Navigate().GoToUrl("http://www.google.com");
driver.FindElement(By.Id("lst-ib")).SendKeys("Microsoft" + Keys.Enter);

Exception message is:

Unable to locate element:{"method":"id";"selector";"lst-ib"}

Gabriel Luci
  • 38,328
  • 4
  • 55
  • 84

1 Answers1

0

I couldn't find the element with id="lst-ib" at the link you provided, but if you're interested in sending the keys to the search bar, you may instead be able to find it by name like:

driver.FindElement(By.CssSelector("input[name='q']")).SendKeys("Microsoft" + Keys.Enter);

Alternatively, I might have missed the element with the id you specified above, in which case you can try to wait for it to appear on the page using WebDriverWait.

AbsoluteSpace
  • 710
  • 2
  • 11
  • 21