Piggy
Piggy

Reputation: 151

Sending key presses to elements

I try to run the example from here

In firefox using firebug for google write box I can see this to find the id:

<input id="gs_htif0" class="gsfi" disabled="" autocomplete="off" aria-hidden="true" style="border: medium none; padding: 0px; margin: 0px; height: auto; width: 100%; position: absolute; z-index: 1; background-color: transparent; color: silver; transition: all 0.218s ease 0s; opacity: 0; text-align: left; left: 0px;" dir="ltr">

Using the following code:

library("RSelenium")
startServer()
checkForServer()
remDr <- remoteDriver()
remDr$open()
remDr$navigate("https://www.google.com/")
webElem <- remDr$findElement(using = "xpath", "//*/input[@id = 'gs_htif0']")
webElem$sendKeysToElement(list("R Cran", "\uE007"))

The error I receive is the following:

Error:   Summary: InvalidElementState
     Detail: An element command could not be completed because the element is in an invalid state (e.g. attempting to click a disabled element).
     class: org.openqa.selenium.InvalidElementStateException

Upvotes: 1

Views: 258

Answers (1)

Helping Hands
Helping Hands

Reputation: 5396

It seems you have used incorrect xpath , Correct xpath for google search box is //*[@id="lst-ib"]

Hope it will solve your issue.

Upvotes: 2

Related Questions