Earlier I blogged about setting up Selenium, PHPUnit et al on an Ubuntu machine.
Although I prefer to do web development on an Ubuntu machine, for 'legacy' reasons I still do some stuff on a Windows machine. For lighter web interface testing, a full CI tool like Hudson is overkill. Here's how to run Pear's Selenium_Testing alone (without PHPUnit) on Windows.
I assume you have PHP and the Pear installer on your Windows machine. Grab the Pear Selenium_Testing package with :
- pear install Testing_Selenium-0.4.3
Next download Selenium RC from here : http://seleniumhq.org/download/
Start a command window and go to where you unzipped your download. Start the Selenium RC server with this :
- C:\SeleniumRC\selenium-remote-control-1.0.3\selenium-server-1.0.3> java -jar selenium-server.jar
This assumes you have a Java 1.6 JRE on your Windows system.
When you start the Selenium RC server, you'll get feedback like this in the command window :
22:16:17.605 INFO - Java: Sun Microsystems Inc. 1.6.0_03-b05
22:16:17.605 INFO - OS: Windows XP 5.1 x86
22:16:17.605 INFO - v2.0 [a2], with Core v2.0 [a2]
22:16:17.839 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
22:16:17.839 INFO - Version Jetty/5.1.x
22:16:17.839 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
Here's a simple test you can try. Make sure you first install the Firefox screen capture tool at http://www.screengrab.org to capture screenshots :
start(); $selenium->open("http://google.com"); if ($selenium->getTitle() == 'Google') { print "Title equals Google\n"; } else { print "Title is not Google\n"; } $selenium->type("q", "luhman"); $selenium->click("btnG"); $selenium->waitForPageToLoad(3000); $selenium->captureEntirePageScreenshot('c:\tmp\screenCap.png', ''); if ($selenium->isTextPresent('luhman.org')) { print "Found luhman.org \n"; } else { print "Did not find luhman.org\n"; } $selenium->stop(); } catch (Selenium_Exception $e) { echo $e; }