Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Daemon mode breaks RSelenium's navigate() method #13

Open
cpsievert opened this issue Jan 30, 2015 · 3 comments
Open

Daemon mode breaks RSelenium's navigate() method #13

cpsievert opened this issue Jan 30, 2015 · 3 comments

Comments

@cpsievert
Copy link
Contributor

For animint, we've been using servr and RSelenium to test whether plots are rendered in the browser the way we expect. Plot rendering requires a file server, so before I discovered the new daemon support, I did something like:

library(servr)
library(RSelenium)
cmd <- "R -e \'cat(Sys.getpid(), file=\"pid.txt\"); servr::httd(dir=system.file(\"examples/make1\", package=\"servr\"), port=4848, browser=FALSE)\'"
system(cmd, wait = FALSE)
# start selenium server, open firefox, and navigate to file server on localhost
checkForServer(dir=system.file("bin", package = "RSelenium"))
startServer()
remDr <- remoteDriver(browserName = "firefox")
remDr$open(silent = TRUE)
remDr$navigate("http://localhost:4848/")
# kill the file server
tools::pskill(readLines("pid.txt", warn = F))

However, I run into problems if I use daemon=TRUE

res <- httd(dir = system.file("examples/make1", package = "servr"), 
            daemon = TRUE, port = 4848, browser = FALSE)
# The line below freezes firefox & the R session. However, it works if I _manually_ navigate there
# I can also use other methods like `remDr$getPageSource()`
remDr$navigate("http://localhost:4848/")

Any ideas why the daemon approach might cause this problem? Is there a somewhat simple explanation of the difference between the two approaches? Maybe @johndharrison could help? I don't think it's a browser issue as I've also tested this with phantomjs.

@yihui
Copy link
Owner

yihui commented Feb 3, 2015

I'm in China this month, and I'm behind the Great Fire Wall. It's inconvenient for me to download Selenium, so I have no idea here.

@cpsievert
Copy link
Contributor Author

No worries. I can always go with the first approach. Enjoy China!

@johndharrison
Copy link

This seems to be an issue when RStudio is used as an IDE. Using the RGui or command line R I don't seem to encounter this issue.

library(RSelenium)
library(servr)
remDr <- remoteDriver(browserName = "chrome")
remDr$open(silent = TRUE)
res <- httd(dir = system.file("examples/make1", package = "servr"), 
            daemon = TRUE, port = 4848, browser = FALSE)

remDr$navigate("http://localhost:4848/")

The navigate method completes for me in the background what I observe is RStudio "R Session Aborted".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants