1

I am new in using RSelenium, I wanted to simply click a load data button and then click the generated CSV from a webpage, but I cant find the element properly, here is what I do:

library(RSelenium)
library(dplyr)
library(tidyverse)
mydriver <- rsDriver(browser = "chrome", port= 4837L, chromever="93.0.4577.63")
remDr <- mydriver[['client']]
remDr$open()
link_download <- "https://forexsb.com/historical-forex-data"
remDr$navigate(link_download)

These are several ways of what I use to select the load data button, but produce No Such Element Found:

load_data_element <- remDr$findElement(using="css selector", value="#btn btn-primary")
load_data_element$clickElement()
load_data_element <- remDr$findElement(using="css selector", value=".btn-load-data")
load_data_element$clickElement()
load_data_element <- remDr$findElement(using="xpath", value="//button[@id='btn-load-data']")
load_data_element$clickElement()
load_data_element <- remDr$findElement(using="xpath", value="//*[@id='btn-load-data']")
load_data_element$clickElement()

And this is The Only Selector which found some element, but still nothing happen when it is clicked:

load_data_element <- remDr$findElement(using="xpath", value="//button")
load_data_element$clickElement()

Any guide will be helpful, Thankyou!

Nad Pat
  • 3,129
  • 3
  • 10
  • 20
Jovan
  • 763
  • 7
  • 26
  • I was able to find some elements but it showed `Compound class names not permitted`. Try to refer https://stackoverflow.com/questions/37771604/selenium-compound-class-names-not-permitted https://stackoverflow.com/questions/37771604/selenium-compound-class-names-not-permitted/50549015 – Nad Pat Sep 20 '21 at 04:51
  • @NadPat I thought that it was amusing that it didnt get the load button correctly, but then I realize that the element what I want to get is inside an `Iframe`.. so I think I already found the solutions, thankyou for the references as well – Jovan Sep 20 '21 at 05:59

1 Answers1

0

The Load Data Button and CSV Generated Download was all in an iframe, so this should make the element clickable after switching focus to Iframe:

iframe_detect <- remDr$findElements(using = "xpath", value = "//iframe[@id='data-app-frame']")
remDr$switchToFrame(iframe_detect[[1]])
load_data_element <- remDr$findElement(using="xpath", value="//button[@id='btn-load-data']")
load_data_element$clickElement()
Jovan
  • 763
  • 7
  • 26