Automated Browser Testing using Selenium
I just started using Selenium for automated browser testing. It's turning out to be really nice as a kind of SharePoint site warm up script too. This is what I've got running on my box right now for automated tests on a schedule:
Setting up a Selenium test script to run on a schedule on Windows 7- Create a directory on your local system c:\selenium
- Install the seleniumn IDE FireFox plugin for recording/saving tests.
- Record a browser test with a starting point of https://www.google.com.
- save the test as c:\selenium\MyGoogleTest.html.
- Save the test suite as c:\selenium\MyGoogleTestSuite.html.
- Download selenium-server-standalone-2.40.0.jar so you can run test scripts from the command line
- copy the selenium-server-standalone-2.40.0.jar to c:\selenium\selenium-server-standalone-2.40.0.jar
- create a bat file to run your test script command c:\selenium\RunMyGoogleTest.bat
- Edit the bat file and paste in this command: java -jar selenium-server-standalone-2.40.0.jar -htmlSuite "*firefox" "https://www.google.com/" "c:\selenium\MyGoogleTestSuite.html" "c:\Selenium\results.html"
- Open a command prompt, change the current directory to c:\selenium and run RunMyGoogleTest.bat. Firefox should launch and show your tests being performed.
- Create a new windows scheduled task. In the action tab, add a new action.
- Action: Start a program
- Program/Script: C:\Selenium\RunMyGoogleTest.bat
- Start in (optional): c:\Selenium
- You can setup the task to run as any user that's ever logged onto your computer. So if you dont want to see windows opening every time the task runs, change the user the task runs as something other than your user account.
- Run the scheduled task by hand to confirm it works. Again, it should launch firefox and run your tests.
You can force selenium to run the test slower by hacking up the test suite html. After the open command you can add setSpeed command that will force every clickAndWait method to pause before running the next command, giving the browser time to load page content. For more info - http://www.jnhasty.com/2013/02/15/using-the-setspeed-setting-in-selenium-standalone-htmlsuite-mode/