Back

Explore Courses Blog Tutorials Interview Questions
0 votes
4 views
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:

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?

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)
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

30.5k questions

32.6k answers

500 comments

108k users

Browse Categories

...