Search code examples
rseleniumrselenium

RSelenium - I can't click in a checkbox and then click in the submit button


I have been trying to select one item from drop-down menu, and than click in a check-box and than click in the submit button.

But I can't click in the check-box. There is no error or messages. Nothing happens. I also can't find the submit button to click.

My code:

library(magrittr)

driver <- RSelenium::rsDriver(browser="firefox", port=4545L, verbose=F) # Instala o "firefox" e define como padrão para o selenium
remote_driver <- driver[["client"]]
remote_driver$navigate("https://www.bcb.gov.br/estabilidadefinanceira/encontreinstituicao")
Sys.sleep(3) 

tableElem <- remote_driver$findElement(using = "xpath", value = "//div[@class = 'container main']//iframe")
remote_driver$switchToFrame(tableElem)

remote_driver$findElement(using = "id", value = "segmento")
option <- remote_driver$findElement(using = 'xpath', "//select[@id='segmento']/option[@value='object:78']")
option$clickElement()

#Not working
relo <- remote_driver$findElement(using = "id", value = "incluirInstituicoesPesquisa")
relo$clickElement()

#not working
pesq <- remote_driver$findElement(using = "class", value = "btn btn-primary")
pesq$clickElement()

Site

The check box I want to click is "Incluir instituições em regime especial e liquidação ordinária".

The button I want to click is "Pesquisar".

enter image description here

What am I missing?


Solution

  • I did it.

    relo <- remote_driver$findElement(using = "xpath", value = "/html/body/section/div/div/ui-view/section/div/div[1]/form/div[8]/label")
    relo$clickElement()
    
    pesq <- remote_driver$findElement(using = "xpath", value = "/html/body/section/div/div/ui-view/section/div/div[1]/form/div[9]/button[1]")
    pesq$clickElement()
    

    I didn't know we can copy the right xpath.