Testing Tuesday #5: Test your web apps with Selenium

Testing Tuesday

This is the fifth Testing Tuesday episode. Every week we will share our insights and opinions on the software testing space. Drop by every Tuesday to learn more! Last week we talked about deploying an application with Cucumber and Codeship to Heroku.

Codeship – A hosted Continuous Deployment platform for web applications


Testing with Selenium

Selenium is a remote control for your browser. The official version is a plugin for Firefox, but there are also inofficial releases for other browsers. Selenium lets you perform browser actions by creating scripts instead of using your mouse or keyboard. There may be many use cases for Selenium, but the best and most popular is testing. In this screencast I present the two Selenium tools Selenium IDE and Selenium WebDriver.

Selenium IDE

Selenium IDE lets you record and playback tests for your web application in the browser. You just perform a few actions like clicking links or filling in forms. Then you define a desired outcome, like there should be a certain headline. Once this is done, you can replay the test case at any time to make sure your application still works. You don’t need any programming knowledge to create these tests, so this is the perfect tool to get started with testing.

Selenium WebDriver

The power of a full web browser for your testing framework. Selenium WebDriver lets you run your integration tests in the web browser. This has many benefits like being able to test pages that rely on Javascript. But it’s also nice to see your tests run in the browser, so you can easily figure out what’s happening and what’s going wrong. In the screencast I show you how easy it is to run your Cucumber scenarios in the web browser with Selenium.

Up next week: Top 5 Cucumber Practices!

Let me know your ideas for any Testing Tuesday episodes! I’d love to cover your favorite testing framework, answer questions or dig a little deeper into Continuous Integration. Just leave a comment or drop me a line!

Further info:

Subscribe via Email

Join 16,045 Newsletter Subscribers.

Join the Discussion

Leave us some comments on what you think about this topic or if you like to add something.

  • http://root-project.org/ SeriousM

    selenium is able to run the tests with phantomJS as well. how does that influence the tests?

    • Clemens Helm

      Hi, I’m not sure if I get the question correctly. Did you mean that Cucumber is able to run the tests with phantomJS?

      • http://root-project.org/ SeriousM

        you imagined that selenium can catch ui bugs like hidden elements. selenium can use several browsers as well as phantomJS. can phantomJS also catch such ui bugs?

        • Clemens Helm

          Yes, phantomJS can also catch these kinds of errors. We used it before with the poltergeist Capybara driver (https://github.com/jonleighton/poltergeist) but in my experience Selenium with Firefox runs more stable and if something goes wrong it’s easier to find the problem – also because you’ve got visual feedback in the browser.

          • http://root-project.org/ SeriousM

            Alright, that makes sense.
            How do you test different browsers?
            eg Chrome has a different HTML5 support than Firefox or IE (ieeee^^).

          • Clemens Helm

            We don’t test different browsers at all. Most of our users have “modern” web browsers so the differences are negligible for us. However, it’s possible to test IE, Chrome and Opera as well with Selenium. So if your project requires it, you can run the same Selenium tests in all browsers.

  • http://hron.me/ Gábor Garami

    Capybara-webkit is an intermediate solution between simple cucumber testing and full-stack testing. It is faster than selenium, and can trigger js stuffs for testing… See https://github.com/thoughtbot/capybara-webkit

    • Clemens Helm

      Hi Gábor,

      It’s been a while since I checked out capybara-webkit. At Codeship we moved from capybara-webkit to poltergeist because capybara-webkit wouldn’t check if elements were clickable or not (elements covered by other elements were still clickable). After a while we moved from poltergeist to Selenium, because poltergeist was giving us weird errors (I’m looking at you, ObsoleteNode) and the performance difference wasn’t significant.

      But I’m sure that also capybara-webkit evolved and maybe the reasons why we decided against it aren’t valid anymore. What are your experiences with it?

      • http://hron.me/ Gábor Garami

        You say “capybara-webkit wouldn’t check if elements were clickable or not (elements covered by other elements were still clickable)”.

        I think capybara-webkit is not have to cover this problems, because I think to capybara-webkit as an alternative of rack-test testing. So, for example if there is a form what is popovers by jQuery dialog() function, you cannot test it without basic JS support. That’s why I write capybara-webkit is an intermediate solution between simple cucumber tests (what backed by rack-test) and Selenium (what is requires browser for running).

        I think capybara-webkit cannot and should not cover the target what you wrote, it is a possible replacement for rack-test, not for selenium. Testing layer order correctness is not a test of functionality, it is an integration test, especially a design test. You can think to capybara-webkit as a functional test solution.

        Selenium is a bit more than rack-test/capybara, it renders the full webpage with a real browser, so it can cover cases what is not comes out with “functional” testing (dialog is pops over or not?).

        And not only the performance is the only thing what we have to consider when choosing a test framework, but dependencies too. Capybara-webkit can cover most needed cases and it is should be enough for everyday testing, e.g. at every commits. Selenium can test the bit bigger picture, it can test “visible” mistakes too – but I think it should not be a part of the tests what run at every commit/push, because it’s needs to booting up Xvfb and browser, what _can_ be a time-consuming task, especially at bigger projects.

        • Clemens Helm

          Thanks for the good overview! At Codeship we prefer full integration tests for some scenarios, but I think this is a decision depending on the project and also on personal preference.

          We run our complete integration tests suite (Cucumber) almost only on the Codeship Continuous Integration server and we’ve also parallelized test execution so speed is not so much of a problem.

          Also, for scenarios that don’t require Javascript we still use rack_test. But I see how capybara-webkit can be a performant all-in-one solution.

          By the way, I saw that you’re from Budapest. Will you attend Rubyslava on May 30? I’ll be there. Or are there any Ruby meetups in Budapest?

          • http://hron.me/ Gábor Garami

            I don’t know any Ruby meetup at Budapest, and I strongly guess I cannot attend on Rubyslava. It’s primarily because currently I do not work in ruby-related job, I’m just a sysadmin. Ruby/Rails is just my hobby now… but I thinking on change this situation.

  • Siva Kandasamy

    For standalone testing suite for webservices, the basic setup is available in https://github.com/sivajankan/standalone-cuke-selenium-download

    Siva

  • Marco

    Selenium is a great tool.

    http://www.web-development-tools.com

  • Andrew Harrop

    nice)!

  • Peter Son

    Your information about selenium is really interesting. Also I
    want to know the latest new techniques which are implemented in Selenium.
    Please update it in your website.

    Selenium
    training Chennai

  • Peter Son

    Your information about Selenium scripts is really
    interesting. Also I want to know the latest new techniques which are
    implemented in selenium. Can you please update it in your website?

    Selenium
    training Chennai

  • http://www.aquademica.se/mogel/ Mögel

    Interesting to see … thank you it’s well done :)

    http://www.aquademica.se

  • teksonit

    Great Information admin thanks For Your Information and Any body wants
    learn Selenium through Online for Details Please go through the Link

    Best Online Selenium Training by IT Professional Trainers

    This Will Helps you aalot.