I am using R, version 3.3.2. I am trying to scrap some data from this website: http://www.dziv.hr/en/e-services/on-line-database-search/patents/
I am using Rselenium and my code looks like this:
webElem <- remDr$findElements("css", "iframe")
remDr$switchToFrame(webElem[[1]])
webel <- remDr$findElement(using = "xpath", "//input[@id = 'TB1']")$sendKeysToElement(list(as.character("*"), key = "enter"))
Sys.sleep(2)
windows_handles <- remDr$getWindowHandles()
Sys.sleep(1)
remDr$switchToWindow(windows_handles[[1]][[2]])
As you can see after third line new windows appear, and I switch to this new window. On this new window, I would like to click on second page on bottom of the page, then 3 and so on. I have tried several solutions, for example:
remDr$findElement(using = "xpath", "//a[contains(text(),'2')]")$clickElement()
remDr$findElement(using = "xpath", "//a[@style = 'color:#333333;']")$clickElement()
remDr$findElement(using = "xpath", "/html/body/form/div[3]/div[1]/div/table/tbody/tr[27]/td/table/tbody/tr/td[2]/a[@href]")$clickElement()
Non of this solutions works. I think this is because of the javascript in href? How can I execute this javascript and continue on second page? I know for executeScript()
function, but not sure how to use it.
jdharrison answeres the question:
You can select the pages using
remDr$executeScript("__doPostBack('GVRezultati','Page$2');")
etc...