Koha ILS
What is Selenium and why we should be using it in Koha
We’ve all heard of unit test and perhaps some of us have even written a few. For those of you that have written unit test I’m sure you’re painfully aware that its pretty much impossible to get good test to see if the front end of your web app is functioning correctly. You could script something with Node.js or WWW::Mechanize to try some rudimentary test but it would still take a programmer to write them. Selenium aims to circumvent the programmer and allow the user to design their own test with a simple to use interface.
What Is Selenium?
Selenium is simple, it automates your browser. You can use selenium for simple use cases, such as: automation scripts, localized test cases, logging in to your email with 1 click. You can also use selenium for more complicated test cases that can be saved into testing suits and distributed across multiple environments and multiple users to allow for more comprehensive testing. For a bit more info checkout the selenium homepage.
Why Should I care?
Weither developers like to admit it or not Javascript is all around us. It makes fancy animations that keep our users happy and makes our lives easier with things like client side form validation. Often developers do our best to make our code degrade nicely without javascript but we still need a way to test the javascript based code when it is rendered in the dom. Typically this boils down to “Hey <friend>, can you go here and let me know if it looks right to you?” Obviously this is not a thorough way of testing, especially if your friend isn’t as familiar with the software as you are. Selenium would like to take your friends place and do all of your front end testing for you. Yes, Selenium wants to be your friend.
How It Works
Selenium has a simple to use “IDE” that is a firefox plugin. Once installed you can start recording test and playing them back. Selenium works by recording the actions you do on the page. For example, you want to log into Koha. Selenium would record that you clicked on the username input and record what you typed. Then you would click on the password input and enter your password, selenium would record that as well. Finally you would click the submit button, which selenium would also record. All actions are recorded as an HTML format that selenium can read but can also be exported to many other languages. Selenium also integrates with Jenkins so when your builds take place you can make sure you’re shipping out good code.
Demo
I’ve created a short video to get you started with selenium testing that I’ll link below. Please feel free to hit me up in the comments for more videos or with any questions you may have.
http://www.screencast.com/users/libsysguy/folders/Jing/media/aa121a0c-6532-4b9d-ab62-063e126665b4
Addendum:
I forgot to mention why we should be using this in Koha (As a developer). I believe this tool could be extremely useful in our QA/Sign-off process. If we submitted selenium test with our patches it would make testing said patches MUCH MUCH easier. This way I can see exactly what you are trying to test in either code form or in automated browser form. So if you want your patch to get through QA faster, consider writing a selenium test for it.
[Originally posted by Elliott Davis]
Read more by ByWater Staff