So open up the IDE. Load in a test and then click the tab called "Source" on the window bar (or where ever) under "Options" go to "Format" and then "Python". It will take your nice GUI test and convert it all to python code. More specifically, a unit test built around the Selenium framework. And the best part is that it is easily runnable, you just copy and paste it into a new file.py and then run it from python. You can easily link many together. So if you have multiple tests, just make a "UIUnitTest.py" file, copy all of one into it and then just grab the "def test_new(self):
" part and paste it in. Python will run it all as one big unit test automatically. Isn't it wonderfull!
However...... For this to run, you must install the Selenium RC package (it is on the same download page). And you must use Unix, Linux or the terminal in OS X. So download it, unzip it and shove it into a directory. The next part you need to visit here on how to set environment variables and point Selenium to the right spot. So go into the folder selenium-remote-control-1.0-beta-2/ and then into selenium-server-1.0-beta-2 . Now run the jar there by java -jar selenium-server.jar . This must be running for you to remote execute things. Make a new terminal and put your UIUnitTest.py file under the one python branch in the selenium-remote-control-1.0-beta-2 folder and then run it. It will automatically launch firefox (remember to have X windows on...) and then run it. And please make sure that it runs correctly before doing this!
Now the great part about running it in the RC version is that you can inject Python code into the unit test file. So if you need to create tables for a database, you can easily do that. Run some script? Go ahead! What ever Python can do, you can put it in and then automate it.
So if you think Selenium will help you in whatever, use it. If not, don't. Oh and remember, the documentation for Selenium is horrible. So if you have a question, ask here I may be able to help.
No comments:
Post a Comment