Setting up Rselenium


#1

hey , not able to use the open command..seems to be some issue with docker,,,docker is installed . chrome webdriver is installed..firefox is installed...connected to selenium server using cmd.

please help ..refer to the pic


#2

I presume you are running the Selenium server within docker locally? Do you mind executing docker ps in the terminal and sharing the output? Of course, you need to execute that command as a user with sufficient privileges.

Have you seen this article? http://rpubs.com/johndharrison/RSelenium-Basics


#3

Sorry, I didn't see the latest reply on the other thread.

I came across the same problem and used the following issue #156 to fix the problem.

The path to firefox must be specified (I'm unsure of the reasoning behind this), but on my local machine the location of the firefox.exe is: C:/Program Files (x86)/Mozilla Firefox/firefox.exe. To get Rselenium server to register the path, use the following code:

rs <- rsDriver(
  browser = "firefox", 
  extraCapabilities = list(
    `mox:firefoxOptions` = list(
      binary = "C:/Program Files (x86)/Mozilla Firefox/firefox.exe"
    )
  )
)

Double check the location of firefox on your system it might be located in Program Files/... instead.


#5

Moved here from: Installing RSelenium
These comments came before the first post in this thread

selenium server is running in cmd, firefox is installed, still i am getting error. refer to the pic


#6

I'm slightly confused with the merged topics. Is the last reply part of the old thread or a new question? Did my last response fix the issue?

I'll combine everything into a single code block. I also provided an example on how to extract the table headers on community.rstudio.com

# install
# devtools::install_github("johndharrison/binman")
# devtools::install_github("johndharrison/wdman")
# devtools::install_github("ropensci/RSelenium")

# load pkg
library(RSelenium)

# initiate selenium     -- start it this way every time
# make sure the location of firefox on your machine is correct
rs <- rsDriver(
  browser = "firefox", 
  extraCapabilities = list(
    `mox:firefoxOptions` = list(
      binary = "C:/Program Files (x86)/Mozilla Firefox/firefox.exe"
    )
  )
)

# shorten access to client
rsc <- rs$client

# navigate to desired site
rsc$navigate("https://community.rstudio.com/")

# example: scrape column headers
table_hr_elem <- rsc$findElements(
  using = "css", 
  value = "table.topic-list.ember-view > thead > tr > th")

# extract values and format
headers <- sapply(table_hr_elem, function(x){x$getElementText()})
colnames <- data.matrix(headers)

If you are having troubles with phantomjs, see this comment on rselenium issue #9.


#7

Sorry, that was me! Trying to clean up the way the original problem statement was split over two threads, but it sounds like I introduced more confusion. The OP hasn’t actually posted again (yet), so I’m afraid no word on whether your solution worked (but these are super helpful answers, so thanks for sticking with the fragmented thread!)