Explore Courses Blog Tutorials Interview Questions
0 votes
in R Programming by (160 points)

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:



driver <- rsDriver(browser=c("chrome"), chromever="88.0.4324.96")
remote_driver <- driver[["client"]]

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:
Build info: version: '-', revision: '-', time: '-'
System info: host: '-', ip: '-', '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?

Please log in or register to answer this question.

Related questions

0 votes
1 answer
asked Nov 12, 2020 in Python by ashely (50.2k points)
0 votes
1 answer
asked Apr 15, 2021 in Java by Jake (7k points)
0 votes
1 answer
0 votes
1 answer
asked Nov 12, 2020 in Python by ashely (50.2k points)

Browse Categories