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

Error running tests_init() #66

Closed
kferris10 opened this issue May 14, 2015 · 17 comments
Closed

Error running tests_init() #66

kferris10 opened this issue May 14, 2015 · 17 comments

Comments

@kferris10
Copy link
Collaborator

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.

> library(animint)
> 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

It also spits out some warning messages which Carson said not to worry about. If I try using Firefox, I get a different error:

> tests_init("firefox")
Undefined error in RCurl call.

Starting selenium binary. To shut it down, run: 
remDr$closeWindow() 
remDr$closeServer()
Undefined error in RCurl call.
Error in queryRD(paste0(serverURL, "/session"), "POST", qdata = toJSON(serverOpts)) : 

Here's my session info, let me know what else I can do to help!

> sessionInfo()
R version 3.1.3 (2015-03-09)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 8 x64 (build 9200)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] animint_2015.05.11 proto_0.3-10       ggplot2_1.0.0.99  

loaded via a namespace (and not attached):
 [1] bitops_1.0-6     caTools_1.17.1   colorspace_1.2-4 digest_0.6.8    
 [5] grid_3.1.3       gtable_0.1.2     MASS_7.3-39      munsell_0.4.2   
 [9] plyr_1.8.1       Rcpp_0.11.5      RCurl_1.95-4.5   reshape2_1.4.1  
[13] RJSONIO_1.3-0    RSelenium_1.3.5  scales_0.2.4     stringr_0.6.2   
[17] tools_3.1.3      XML_3.98-1.1  
@cpsievert
Copy link
Collaborator

First, lets make sure minimal examples with RSelenium work:

  • phantomjs:
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()
  • firefox
library(RSelenium)
checkForServer()
startServer()
remDr <- remoteDriver(browserName = "firefox")
remDr$open()

@kferris10
Copy link
Collaborator Author

  • 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)) :

@cpsievert
Copy link
Collaborator

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)

@kferris10
Copy link
Collaborator Author

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: Problem with remoteDriver() 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'

@kferris10
Copy link
Collaborator Author

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

@cpsievert
Copy link
Collaborator

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

@cpsievert
Copy link
Collaborator

If that works, we should probably make the same changes to the shiny tests.

@kferris10
Copy link
Collaborator Author

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.

@cpsievert
Copy link
Collaborator

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

@kferris10
Copy link
Collaborator Author

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.

@cpsievert
Copy link
Collaborator

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".

@caijun
Copy link
Collaborator

caijun commented May 23, 2015

@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"

@caijun caijun reopened this May 23, 2015
@caijun
Copy link
Collaborator

caijun commented May 25, 2015

ropensci/RSelenium#50

@caijun caijun closed this as completed May 25, 2015
@caijun
Copy link
Collaborator

caijun commented May 25, 2015

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

@cpsievert
Copy link
Collaborator

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") 

@caijun
Copy link
Collaborator

caijun commented May 26, 2015

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)

@cpsievert
Copy link
Collaborator

OK, thanks. I would report that to https://github.com/ropensci/rselenium

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