Programming: Selenium, more than just an element.

Selenium is more than just element 34 on the periodic table. It's also a very cool way of writing functional tests for your web applications.
As an asside I'll describe my foray into testing for web apps.I decided the best way of writing these tests is to make some XML files with commands to create for GET or POST and read the results. I worked fairly well quite quickly, but I saw that I needed to have cookies working to test properly. A little more code and I had cookies. Then I noticed that redirects weren't working. A little more code and I got that working as well. Then I had the problem with pages with passwords - fixed. Then I wanted to test multiple languages, added. Now I have a reasonably complete testing suite for Python which uses XML as the testing source. But then I found some problems with my JavaScript code on the page and realized there was no way for me to test that. I would have to drive IE or Firefox from Python and it was just too much work.
Selenium sidesteps all that by running the tests as JavaScript inside the browser. Any button or item can be clicked, and you have access in the test to all elements and variables. The idea is simple and powerful. There are some issues with regards to cross-site scripting (XSS) which makes things a little harder than necessary (it's a security feature in browsers). The selenium site is a bit of a mess at the moment, it's hard to find some of the information.
I'm going to start using it more, simply because it can test everything. My test script will need to live on the same server as my website, but that's a small price to pay.

Comments

Popular posts from this blog

Shortest Sudoku solver in Python

Seven Segment Display in Inkscape

Dot to Png