Automatically Running Selenium Server from Coldfusion

45 views
Skip to first unread message

Cerin

unread,
Feb 11, 2009, 9:47:20 AM2/11/09
to selenium-users...@googlegroups.com
Has anyone been able to automatically start and stop the Selenium server from a Coldfusion request? I've found some blog posts that show how to incorporate Selenium into unittests using the selenium-java-client-driver.jar, but you still have to manually start selenium-server first, which is the final stumbling block to completely automating the unittests.

I've tried several tricks to launch selenium-server as a sub-process. However, none of them seem to work, and I haven't been able to figure out why.

This is my current strategy. In my unittest's setup(), I start the server using:

var cmd = "java -jar ""#expandPath('/unittests')#\selenium-server.jar"" > selenium.output.txt";\\ var runtime = createObject("java", "java.lang.Runtime");\\ variables.seleniumServer = runtime.getRuntime().exec(cmd);\\ Thread.sleep(1000); // Give the server time to initialize before sending requests to it.
\\ And in my tearDown(), I do:

variables.seleniumServer.destroy();
\\ I know the sub-process is being created, because I can see the new Java process launch when I run my unittests, but all the calls from the client jar result in an "unable to reach the server" error. And for some odd reason, nothing's written to selenium.output.txt.

The other option I had tried was simply initializing an instance of org.openqa.selenium.server.SeleniumServer. Unfortunately, I'm using MX7, which uses a fairly old version of Java that's incompatible with the current selenium-server.jar.

Any help is appreciated.

Chris

Cerin

unread,
Feb 11, 2009, 11:22:51 AM2/11/09
to selenium-users...@googlegroups.com
I figured out how to read the sub-process output from Coldfusion through getInputStream(). Unfortunately, the read() method seems to block until the sub-process is forcefully terminated. However, this is what I get, implying the server seems to be starting up correctly:

11:14:46.337 INFO - Java: Sun Microsystems Inc. 10.0-b23\\ 11:14:46.337 INFO - OS: Windows XP 5.1 x86\\ 11:14:46.337 INFO - v1.0-beta-1 [2201], with Core v1.0-beta-1 [1994]\\ 11:14:46.446 INFO - Version Jetty/5.1.x\\ 11:14:46.446 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]\\ 11:14:46.446 INFO - Started HttpContext[/selenium-server,/selenium-server]\\ 11:14:46.446 INFO - Started HttpContext[/,/]\\ 11:14:46.649 INFO - Started SocketListener on 0.0.0.0:4444

Is it possible that the sub-process isn't actually running as a separate process, and is somehow blocking the main process running Coldfusion? How would I work around this?

The exact error I get from calls to DefaultSelenium is:

DefaultSelenium = createobject("java","com.thoughtworks.selenium.DefaultSelenium");\\ browser = DefaultSelenium.init("localhost", 4444, '*iexplore', "http://www.google.com");\\ browser.start();\\ browser.open("/");\\ browser.waitForPageToLoad("30000");\\ WriteOutput('text='&browser.isTextPresent("Privacy")&'<br/>');\\ browser.stop();

Could not contact Selenium Server; have you started it? Catch body broken: IOException from cmd=getNewBrowserSession&1=*iexplore&2=http%3A%2F%2Fwww.google.com -> java.net.ConnectException: Connection refused: connect

Reply all
Reply to author
Forward
0 new messages