Closed kferris10 closed 9 years ago
First, lets make sure minimal examples with RSelenium work:
Sys.which("phantomjs") # if this return an empty string you need to set your PATH to find phantomjs
library(RSelenium)
pJS <- phantom()
Sys.sleep(3)
remDr <- remoteDriver(browserName = "phantomjs")
remDr$open()
pJS$stop()
library(RSelenium)
checkForServer()
startServer()
remDr <- remoteDriver(browserName = "firefox")
remDr$open()
phantomjs:
Everything worked fine. I can paste the output if you want.
firefox:
I got this error:
remDr$open() [1] "Connecting to remote server" Undefined error in RCurl call. Error in queryRD(paste0(serverURL, "/session"), "POST", qdata = toJSON(serverOpts)) :
Hmm, sometimes the server needs a few seconds to startup, so try this:
library(RSelenium)
checkForServer()
startServer()
Sys.sleep(5)
remDr <- remoteDriver(browserName = "firefox")
remDr$open()
If you still get an error, that is probably something that should be reported here (make sure to include your devtools::session_info()
)
As for phantomjs, could you try tests_init()
again and include all the output you see? Also, try to make sure there is no Java process running in the background when you try that (RSelenium::startServer()
will start Java and RSelenium::stopServer()
will stop it)
I've tried both of these with the version of RSelenium
on CRAN (1.3.5) and on GitHub (1.3.6)
Firefox
Still seem to be getting the same problem. I also tried sleeping for 15 seconds and still had the same issue. I've posted the issue on the RSelenium project page here: ropensci/RSelenium#49
phantomjs
Before I try that, I can't seem to find stopServer()
RSelenium::startServer() Warning message: running command '"java" -jar "C:/Users/chessa015/Documents/R/win-library/3.1/RSelenium/bin/selenium-server-standalone.jar" -log "C:/Users/chessa015/Documents/R/win-library/3.1/RSelenium/bin/sellog.txt"' had status 127
RSelenium::stopSever() Error: 'stopSever' is not an exported object from 'namespace:RSelenium'
The ropensci people pointed out that I need to have java installed. That helped with the firefox issue. A new firefox window opens, and it tries to connect to localhost:4848
. However, it cannot connect.
The good news is that I now get to the same R error as when I try to use phantomjs
tests_init("firefox")
Undefined error in RCurl call.
Starting selenium binary. To shut it down, run:
remDr$closeWindow()
remDr$closeServer()
Error: Summary: NoSuchElement
Detail: An element could not be located on the page using the given search parameters.
class: org.openqa.selenium.NoSuchElementException
Hmm, could you try changing localhost
to 127.0.0.1
here?
http://superuser.com/questions/713491/why-does-localhost-not-work-in-windows-8-1-but-127-0-0-1-does
If that works, we should probably make the same changes to the shiny tests.
Still getting the same issue unfortunately.
> tests_init()
Starting phantomjs binary. To shut it down, run:
pJS$stop()
Error: Summary: NoSuchElement
Detail: An element could not be located on the page using the given search parameters.
class: org.openqa.selenium.NoSuchElementException
The traceback output
5 stop(errMessage, call. = FALSE)
4 checkStatus()
3 queryRD(paste0(serverURL, "/session/", sessionInfo$id, "/element"),
"POST", qdata = toJSON(list(using = using, value = value)),
json = TRUE)
2 remDr$findElement("xpath", "//a[@href='animint-htmltest/']") at testHelpers.R#54
1 tests_init()
I get the same error when I try to use firefox as well.
Before the Starting phantomjs binary
message, you should see a message that a local file server is serving files under animint's testthat directory, for example, I see:
> tests_init()
serving the directory /Users/cpsievert/Desktop/github/local/animint/tests/testthat at http://127.0.0.1:4848
Try running this (and show me the output):
path <- animint:::find_test_path()
path # make sure this is the full path to the testthat/ folder
animint:::run_servr(port = 4848, path) # this _should_ display a message
browseURL("http://localhost:4848/") # if everything worked, you'll see files under testthat/ listed in your browser
I don't see the serving the directory
message.
Is this a Windows issue? It looks like the forward and backslashes in the path are messed up.
> path <- animint:::find_test_path()
> path # make sure this is the full path to the testthat/ folder
[1] "C:\\Users\\chessa015\\Documents\\packages\\animint/tests/testthat"
> animint:::run_servr(port = 4848, path) # this _should_ display a message
[1] 4848
> browseURL("http://localhost:4848/")
This just opened a blank web page so it did not work.
Ah, OK, this exposed some poor programming on my part. This line should probably be file.path("tests", "testthat")
, not "tests/testthat"
Would you mind making that fix and creating a pull request? The topic could be something along the lines of "get testing working on Windows".
@cpsievert I ran tests_init("firefox")
and encountered following error
Starting selenium binary. To shut it down, run:
remDr$closeWindow()
remDr$closeServer()
Operation in progressOperation in progressfailed to load external entity "http://selenium-release.storage.googleapis.com"
Error: 1: Operation in progress2: Operation in progress3: failed to load external entity "http://selenium-release.storage.googleapis.com"
ropensci/RSelenium#50
When I run tests_init()
in following order
> system("lsof -i :4444")
> tests_init("firefox")
Starting selenium binary. To shut it down, run:
remDr$closeWindow()
remDr$closeServer()
Operation in progressOperation in progress
Warning messages:
1: closing unused connection 4 (/Users/tonytsai/Documents/R/packages/animint/tests/testthat/pids.txt)
2: closing unused connection 3 (/Users/tonytsai/Documents/R/packages/animint/tests/testthat/pids.txt)
> system("lsof -i :4444")
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 3818 tonytsai 41u IPv6 0x597a79eab4bbeab5 0t0 TCP *:krb524 (LISTEN)
> tests_exit()
> system("lsof -i :4444")
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 3818 tonytsai 41u IPv6 0x597a79eab4bbeab5 0t0 TCP *:krb524 (LISTEN)
> system("lsof -i :4444")
> tests_init("firefox")
Starting selenium binary. To shut it down, run:
remDr$closeWindow()
remDr$closeServer()
Operation in progressOperation in progress
Warning message:
In file(con, "r") :
cannot open file '/Users/tonytsai/Documents/R/packages/animint/tests/testthat/pids.txt': No such file or directory
> system("lsof -i :4444")
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 3876 tonytsai 43u IPv6 0x597a79eaa1368bb5 0t0 TCP *:krb524 (LISTEN)
> tests_exit()
> system("lsof -i :4444")
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 3876 tonytsai 43u IPv6 0x597a79eaa1368bb5 0t0 TCP *:krb524 (LISTEN)
> tests_init()
Starting phantomjs binary. To shut it down, run:
pJS$stop()
[ERROR - 2015-05-25T04:06:43.537Z] GhostDriver - main.fail - {"line":85,"sourceURL":":/ghostdriver/main.js","stack":"\tat global code (:/ghostdriver/main.js:85:56)"}
:262 in error
Warning messages:
1: In file(con, "r") :
cannot open file '/Users/tonytsai/Documents/R/packages/animint/tests/testthat/pids.txt': No such file or directory
2: closing unused connection 8 (/Users/tonytsai/Documents/R/packages/animint/tests/testthat/pids.txt)
3: closing unused connection 7 (/Users/tonytsai/Documents/R/packages/animint/tests/testthat/pids.txt)
4: closing unused connection 6 (/Users/tonytsai/Documents/R/packages/animint/tests/testthat/pids.txt)
5: closing unused connection 5 (/Users/tonytsai/Documents/R/packages/animint/tests/testthat/pids.txt)
6: closing unused connection 4 (/Users/tonytsai/Documents/R/packages/animint/tests/testthat/pids.txt)
7: closing unused connection 3 (/Users/tonytsai/Documents/R/packages/animint/tests/testthat/pids.txt)
> system("lsof -i :4444")
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 3876 tonytsai 43u IPv6 0x597a79eaa1368bb5 0t0 TCP *:krb524 (LISTEN)
I got the following error and PhantomJS doesn't successfully start up since the default port 4444 of PhantomJS is possessed by other process, java
in my case. see detro/ghostdriver#394
[ERROR - 2015-05-25T04:06:43.537Z] GhostDriver - main.fail - {"line":85,"sourceURL":":/ghostdriver/main.js","stack":"\tat global code (:/ghostdriver/main.js:85:56)"}
:262 in error
Hence, instead of killing processes recorded in pid.txt, test_exit()
should clean up all processes listening on the given port and default port of PhantomJS. I will give a try and present the results. @cpsievert
Hey @caijun, please try the following:
system("lsof -i :4444")
library(RSelenium)
startServer()
Sys.sleep(5)
remDr <- remoteDriver(browserName = "firefox")
remDr$open()
system("lsof -i :4444")
remDr$closeServer()
# if java is still running at this point, we should report an issue to RSelenium
system("lsof -i :4444")
Hi @cpsievert , I run the codes and java is still running at on my Mac OS 10.10.3 Yosemite.
> system("lsof -i :4444")
> library(RSelenium)
> startServer()
> Sys.sleep(5)
> remDr <- remoteDriver(browserName = "firefox")
> remDr$open()
[1] "Connecting to remote server"
[[1]]
[1] "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n<html><head>\n<title>Proxy error: 502 Server dropped connection.</title>\n</head><body>\n<h1>502 Server dropped connection</h1>\n<p>The following error occurred while trying to access <strong>http://localhost:4444/wd/hub/session/</strong>:<br><br>\n<strong>502 Server dropped connection</strong></p>\n<hr>Generated Tue, 26 May 2015 08:23:10 CST by Polipo on <em>TTMBP.local:8123</em>.\n</body></html>\r\n"
$id
[1] NA
> system("lsof -i :4444")
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 9739 tonytsai 41u IPv6 0x597a79eab14af6b5 0t0 TCP *:krb524 (LISTEN)
> remDr$closeServer()
> system("lsof -i :4444")
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 9739 tonytsai 41u IPv6 0x597a79eab14af6b5 0t0 TCP *:krb524 (LISTEN)
OK, thanks. I would report that to https://github.com/ropensci/rselenium
I'm trying to familiarize myself with the testing workflow for animint. @cpsievert has pointed me to the testing wiki to get started, but I have been unable to run
tests_init()
without an error.It also spits out some warning messages which Carson said not to worry about. If I try using Firefox, I get a different error:
Here's my session info, let me know what else I can do to help!