Rselenium - How to click the check-box and then the Submit button

Asked

Viewed 25 times

-1

I’m trying to make a web scraping of the Central Bank website. To do this, I need to select an item from the drop-down menu, then mark a check box and then click the Submit button.

But when I try to click on the check-box, nothing happens. And I can’t find the Submit button.

My code

library(magrittr)

driver <- RSelenium::rsDriver(browser="firefox", port=4545L, verbose=F) 
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()

# Não acontece nada
relo <- remote_driver$findElement(using = "id", value = "incluirInstituicoesPesquisa")
relo$clickElement()

# Não encontro o botão Pesquisar
pesq <- remote_driver$findElement(using = "class", value = "btn btn-primary")
pesq$clickElement()

Website

The check box I want to check is the "Include institutions in special regime and ordinary settlement". The button I want to click is "Search".

inserir a descrição da imagem aqui

1 answer

0


I got.

Just replace the part that doesn’t work with:

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()

Right-clicking on the area and going to "Inspect element", in the area "Inspector" da para copie o xpath certinho.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.