InfoQ

News

Is Selenium worth the pain?

Posted by Scott Delap on Aug 03, 2007 05:42 PM

Community
Java,
Agile
Topics
Web Frameworks ,
Agile Techniques ,
Unit Testing
Tags
Testing ,
Selenium
Is Selenium worth the pain? Atlassian developer Nick Menere has asked that very question on the Atlassian Developer Blog. Selenium is a test tool for web applications that runs directly in a browser. In his blog post Menere looks at the roadblocks found while trying to use Selenium to test two new Ajax features of JIRA 3.10. The roadblocks included:

Key Events

It turns out selenium.type(...) doesn't actually simulate a user typing into an input box. Go figure. So we typed in the text and triggered everykey stroke seperately - selenium.keyDown(...); selenium.keyPress(...); selenium.keyUp(...);. It worked!! in Firefox... In other browsers, it would now would print every character twice.

 

Timings

..Due to our non-selectable items (section labels etc.), we wanted to test that some elements attributes do not change. We fire a mouse event on the element, and then use an xpath locator to check that the element's attribute did not change ... it needed a slight pause between the event fire and test ... This was a very common fix for a lot of the things that would break - "Add/increase the pause".

Mouse Positioning Issues

To make things a little nicer for our users we decided to put in an autoscroll feature.... After putting in/increasing numerous pauses, I still couldn't get them to pass. Why would scrolling the screen cause the tests to fail? We fire events on selected elements - not co-ordinates. The build kept on breaking......I saw the mouse positioned directly in the middle of the screen, when the browser window scrolled, the mouse was positioned over one of the non-selectable items ... How to fix? We installed xwarppointer, to enable us to move the mouse pointer through bash, and tucked it away in a little corner.

Overall Menere learned a number of lessons. The most important of which was that the Selenium client is not a user.

17 comments

Watch Thread Reply

Selenium pains by Abbas Raza Posted Aug 4, 2007 2:00 AM
Selenium is good by J House Posted Aug 4, 2007 6:02 PM
Re: Selenium is good by emrah okay Posted Apr 30, 2009 10:44 PM
Develop Selenium! by Kunal Shah Posted Aug 5, 2007 9:07 AM
Re: Develop Selenium! by Tim Vernum Posted Aug 5, 2007 9:46 AM
Re: Develop Selenium! by Alex Popescu Posted Aug 6, 2007 6:37 AM
Re: Develop Selenium! by emrah okay Posted Jun 19, 2009 7:23 AM
Yes - is it worth the pain by Reg Whitton Posted Aug 6, 2007 8:31 AM
Re: Yes - is it worth the pain by Reg Whitton Posted Aug 6, 2007 8:52 AM
URL for Blog Article by Eric Pugh Posted Aug 6, 2007 9:54 AM
Re: URL for Blog Article by Deborah Hartmann Posted Aug 6, 2007 8:35 PM
Try Sahi by Greg Willits Posted Aug 6, 2007 1:13 PM
Re: Try Sahi by Alex Popescu Posted Aug 6, 2007 2:18 PM
Selenium Woks! by Alvaro Gareppe Posted Aug 7, 2007 9:29 AM
Re: Selenium Woks! by Judit Raj Posted Nov 26, 2008 12:01 AM
Re: Selenium Woks! by emrah okay Posted Apr 12, 2009 11:54 PM
Chickenfoot another contender by Alex Popescu Posted Aug 7, 2007 3:01 PM
  1. Back to top

    Selenium pains

    Aug 4, 2007 2:00 AM by Abbas Raza

    We have been going through similar pains with Selenium. Sometimes Selenium fails without any deterministic reason. We could figure some issues within our test usage. However, there are other failures which are totally random and do not give any clue. Running from command prompt with maven resulted in test failures at different places than the ones that appear when tested from within eclipse. Arggh.

  2. Back to top

    Selenium is good

    Aug 4, 2007 6:02 PM by J House

    While I agree Selenium can be a pain to work with against ajax enabled pages, I personally think it is a great product - it's free!!! - it is not even on version 1 yet (0.9.0), can only get better - API's exist for multiple programming languages by the way the 'Atlassian Developer Blog' link in the article is busted - prefixed with 'link:'

  3. Back to top

    Develop Selenium!

    Aug 5, 2007 9:07 AM by Kunal Shah

    Selenium is great! But not so great to put it into production. Developers can use it randomly to assist them. It fits with agile practices, but can not run reliably in production yet. I am not sure why the development is so slow (no updates since dec 2006). With Web2.0 applications, so many languages and browsers, (functional) testing on a regular basis is necessary. I would suggest to develop Selenium without going into conclusions (like pain).

  4. Back to top

    Re: Develop Selenium!

    Aug 5, 2007 9:46 AM by Tim Vernum

    But not so great to put it into production
    What do you mean by "production" ? Selenium is a testing tool, by its very nature it doesn't get used in production. Are you suggesting that developers should write Selenium tests for the purposes of development, but not run them as a regular test suite? If so, then that seems like a very strange position to take.

  5. Back to top

    Re: Develop Selenium!

    Aug 6, 2007 6:37 AM by Alex Popescu

    Are you suggesting that developers should write Selenium tests for the purposes of development, but not run them as a regular test suite? If so, then that seems like a very strange position to take.
    I think that what Kumal means is that atm you cannot rely on these tests. You can definitely write and run them periodically, but you shouldn't bet your release on just the fact that your Selenium tests passed. At least this is the way I've read his message. ./alex -- .w( the_mindstorm )p. ________________________ Alexandru Popescu Senior Software Eng. InfoQ TechLead&CoFounder

  6. Back to top

    Yes - is it worth the pain

    Aug 6, 2007 8:31 AM by Reg Whitton

    It is worth it. I have used HttpUnit for a few years and that had some advantages. The best was that once you have written your test, you could start it on a great many threads and knock seven bells out of your server. This is not so easy with Selenium as it requires one instance of FireFox, IE or another to simulate one user. However, writting the test in the first place is much easier with Selenium IDE, and keeping it upto date as the UI changes is quite easy too. With HttpUnit I quite often had to revert to debugging my unit test to see what was in the page that had been returned by the server. OK using Selenium with AJAX isn't a smooth ride yet. I think selenium.type() will set the value of the node in the DOM instead of simulating key presses. However, one of the really nice things about Selenium is where it doesn't quite do what you need, it is very easy to extend. Create your own user-extensions.js, put the following in it, and set up the extensions file in the options:

    Selenium.prototype.doTypeKeys = function(locator, value) {
        for(var i=0; i
    You should now have a typeKeys command that individually enters the keys into the target.  This can drive each browser differently, while keeping your unit test unchanged.
    				
    			

  7. Back to top

    Re: Yes - is it worth the pain

    Aug 6, 2007 8:52 AM by Reg Whitton

    On thinking about it - you probably shouldn't do both a keyPress and a keyUp. You should only need keyDown and a keyUp, any onKeyPress event handler would still be fired. May be this why you get double key strokes in other browsers to FireFox.

  8. Back to top

    URL for Blog Article

    Aug 6, 2007 9:54 AM by Eric Pugh

  9. Back to top

    Try Sahi

    Aug 6, 2007 1:13 PM by Greg Willits

    http://sahi.co.in/ -- from what I have seen, it's pretty good at behaving like a user

  10. Back to top

    Re: Try Sahi

    Aug 6, 2007 2:18 PM by Alex Popescu

    I must confess that at first glance Sahi looks impressive. Thanks for sharing. ./alex -- .w( the_mindstorm )p. ________________________ Alexandru Popescu Senior Software Eng. InfoQ TechLead&CoFounder

  11. Back to top

    Re: URL for Blog Article

    Aug 6, 2007 8:35 PM by Deborah Hartmann

    First link in this item now fixed, thanks for pointing it out.

  12. Back to top

    Selenium Woks!

    Aug 7, 2007 9:29 AM by Alvaro Gareppe

    I've been working with selenium since last year and it´s great for web test. It´s true that ajax have been a problem for selenium but the extensibility allows anything. The posibility of implemet new commands have allowed me, and my company, to solve the problems implementing personalized comands. Selenium: It works... and if it doesn´t you could make it work!

  13. Back to top

    Chickenfoot another contender

    Aug 7, 2007 3:01 PM by Alex Popescu

    Another contender may be: Chickenfoot. Funny name, isn't it? :-). ./alex -- .w( the_mindstorm )p. ________________________ Alexandru Popescu Senior Software Eng. InfoQ TechLead&CoFounder

  14. Back to top

    Re: Selenium Woks!

    Nov 26, 2008 12:01 AM by Judit Raj

    hi, i am judit... i have a doubt.... when i am clicking a link in a page it is opening it in a new tab... how to verify whether the new page is opened....

  15. Back to top

    Re: Selenium Woks!

    Apr 12, 2009 11:54 PM by emrah okay

    With twenty-four members plus two spec leads, Java EE 6 -- or JSR-316 -- is officially underway, Roberto Chinnici presents a summary from the first meetings between the group saç  video izle program indir indir amerika Sohbet adana Sohbet izmir Sohbet Ağrı Sohbet aksaray Sohbet almanya Sohbet Adıyaman Sohbet Afyon Sohbet ankara Sohbet Antalya Sohbet istanbul Sohbet Afyon Sohbet Afyon Sohbet Haber Haber oyun indir oyun indir sohbet mp3 indir bedava film izle bedava film izle telefon çet oyun indir indir program indir - chat anyone try to appropriate the IP and patent it without OpenID's consent.

  16. Back to top

    Re: Selenium is good

    Apr 30, 2009 10:44 PM by emrah okay

    With twenty-four members plus two spec leads, Java EE 6 -- or JSR-316 -- is officially underway, Roberto Chinnici presents a summary from the first meetings between the group saç  video izle program indir indir amerika Sohbet adana Sohbet izmir Sohbet Ağrı Sohbet aksaray Sohbet almanya Sohbet Adıyaman Sohbet Afyon Sohbet ankara Sohbet Antalya Sohbet istanbul Sohbet Afyon Sohbet Afyon Sohbet Haber Haber oyun indir oyun indir sohbet mp3 indir bedava film izle bedava film izle telefon çet oyun indir indir program indir - chat anyone try to appropriate the IP and patent it without OpenID's consent.

  17. Back to top

    Re: Develop Selenium!

    Jun 19, 2009 7:23 AM by emrah okay

    With twenty-four members plus two spec leads, Java EE 6 -- or JSR-316 -- is officially underway, Roberto Chinnici presents a summary from the first meetings between the groupmetin 2 indir video izle oyun indir bedava sohbet mp3 indir bedava film izle oyun indir indir program chat anyone try to appropriate the IP and patent it without OpenID's consent. --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- With twenty-four members plus two spec leads, Java EE 6 -- or JSR-316 -- is officially underway, Roberto Chinnici presents a summary from the first meetings between the group saç  video

Educational Content

Bindings, Platforms, and Innovation

This presentation focuses on the Internet and separating myth from fact, history from the future, and the mundane from the imaginative. Bob Frankston presents a vision of what could and should be.

Orchestrating Long Running Activities with JBoss / JBPM

This article explores the use of JBoss and jBPM to implement design solutions that effectively address the issue of orchestrating long running activities.

Neo4j - The Benefits of Graph Databases

This presentation covers the use of graph databases as an optimal solution for data that is difficult to fit in static tables, rapidly evolving data or data that has a lot of optional attributes.

Realistic about Risk: Software development with Real Options

This session introduces Real Options and shows how it can help in running your project. Real Options is a decision-making process that can be used to manage risk.

Communication Flexibility Using Bindings

This article discusses the use of bindings on services and references (including the instance of non-configured bindings) as the means to implement SCA communications in a Web and SOA environment.

Writing DSLs in Groovy

After a short introduction to DSLs, Scott Davis plays with the keyboard showing how to approach the creation of a DSL by typing working snippets of Groovy code that get executed.

Scaling Agile with C/ALM (Collaborative Application Lifecycle Management)

IBM Rational and InfoQ present, Scaling Agile with C/ALM, an eBook showing organizations how to become “finely tuned software delivery machines” by enabling team integration and scaling.

Concurrent Programming with Microsoft F#

Amanda Laucher presents a real life enterprise application written in F#. She shows actual code snippets, explaining design decisions and suggesting how to use some of the F# constructs.