How put a text in Rselenium with sendKeysToElement()?

Hi community,

I'm want to write in box of this page. In the same form fill others field, an finally press enter or apply filter on page. But when I try use sendKeysToElement() don't put the text correctly.

library(RSelenium)

# Establecer conección --------------------------------------------------
remDr <- remoteDriver(remoteServerAddr = "localhost", port = 4444, browserName = "chrome")
remDr$open()
Sys.sleep(2)

# Navegar -----------------------------------------------------------------
remDr$navigate(url = "https://www.genesys-pgr.org/")

# Dar click en [I AGREE] -----------------------------------------------------
Sys.sleep(1)
remDr$findElement(using = 'xpath', "//*[@id='the-app']/div/div[2]/div/div[2]/button")$clickElement()

# Dar click en [ACCESION DATA] -----------------------------------------------------
Sys.sleep(1)
remDr$findElement(using = 'xpath', "//*[@id='the-app']/div/div/div[1]/header/div/div[2]/nav/div[1]/div[1]/span")$clickElement()


# Dar click en [PASSPORTDATA] -----------------------------------------------------
Sys.sleep(1)
remDr$findElement(using = 'xpath', 
                  "//*[@id='the-app']/div/div/div[1]/header/div/div[2]/nav/div[1]/div[2]/div/div/div/div[1]/a/div/span")$clickElement()
## Esperar 5 seg de carga

# Dar click en [HOLDING INSTITUTE] -----------------------------------------------------
Sys.sleep(1)
remDr$findElement(using = 'xpath', 
                  "//*[@id='the-app']/div/div/div[2]/div/div[1]/div/div/div[2]/div/div/form/div[4]/div/span")$clickElement()

address_element <- remDr$findElement(using = 'xpath', 
                  "//*[@id='the-app']/div/div/div[2]/div/div[1]/div/div/div[2]/div/div/form/div[4]/div[2]/div/div/div/div[1]/div/div[1]/div")

address_element$highlightElement()

address_element$clickElement()
address_element$sendKeysToElement(list("COL003",key = "enter"))  # This part dont put the text 

I need put in address_element this text "COL003" and press enter.

Im try with other selectors like css and id, but dont run well.

How make this?

Hi, yeah looks like the ID is used in the label, too. Have you tried making sure it is pointed to the input field with the ID? Something like:

address_element <- remDr$findElement(using = 'xpath',  "//input[@id='auto-institute.code']")
address_element$sendKeysToElement(list("COL003", key = "enter"))
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.