I'm going to scrape this website. Here we have buttons, text boxes, and a dropdown list. For the text boxes I've used these codes:
library(RSelenium)
library(tidyverse)
library(rvest)
binman::list_versions("chromedriver")
driver <- rsDriver(browser=c("chrome"), chromever="88.0.4324.96")
remote_driver <- driver[["client"]]
remote_driver$open()
remote_driver$navigate("https://www.searates.com/")
from_textfield <- remote_driver$findElement(using = 'id', value = 'from')$sendKeysToElement(list("Port Of Limassol, Cyprus"))
to_textfield <- remote_driver$findElement(using = 'id', value = 'to')$sendKeysToElement(list("Port Of Mersin, Turkey"))
For buttons, I used the same way. However, as a result, get this error:
> Land <- remote_driver$findElement(using = "class", value = "_10ALxoWWyBGfz0jUBNjyCC ")
Selenium message: Compound class names not permitted
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/invalid_selector_exception.html
Build info: version: '-', revision: '-', time: '-'
System info: host: '-', ip: '-', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_281'
Driver info: driver.version: unknown
Error: Summary: InvalidSelector
Detail: The argument was an invalid selector (e.g. XPath/CSS).
Further Details: run error details method
Probably, I didn't enter the HTML element incorrectly. <div class="_10ALxoWWyBGfz0jUBNjyCC "> == $0
How can I get exact elements of html?
The same problem occurs for drop-down element selection. While applying the following codes, it only gives me FCL (which is selected while scraping), not all three options.
type <- remote_driver$findElements(using = "class", "_3h5YplC1TbaEavRzxwaYyK") %>%
lapply(function(x){x$getElementAttribute('value')}) %>% unlist
Does anyone have any solution to these problems?