0

We have a large inventory system where we work and making changes has the possibility to break things in other areas. This happens a lot, and it is hard to manually test for everything every time because something even as simple as a Javascript action applied to a text field can stop working.

Most of the manual tests would consist of entering data in certain fields and submitting that and ensuring no errors are given. How would I use Selenium to automate this kind of regression testing?

We have used Unit testing programs such as PHPUnit for other applications which were more standard, however these kinds of tests need to test a whole system, not just isolated parts, so PHPUnit is not as ideal.

1
  • retitled and updated content. Commented Apr 20, 2015 at 17:07

1 Answer 1

2

Yes selenium can be used to automate the manual interaction steps.

It's intended to be used against web browsers and it's widely used and implemented.

However this is only half of the puzzle. Selenium is the core technology in browser automation tools, APIs and frameworks. To actually USE selenium you are going to need to pick an actual implementation.

You can start of with the IDE plug-in for Firefox. This is nearly always referred to as a quick and dirty, temporary solution. It does not need to be. If you use it to record existing interactions and try and play them back, or do selections based on text, then yes, the test suites you create will be brittle. If you use good practices such as css ID's and HTML data-attributes you can create robust and complex automation this way.
It also has the benefit of actually letting you, or even your product team, see the automation for themselves. It has the downside of only running in the browser IDE that it is implemented which I believe is still just Firefox so starting it is still a manual step.

The other, more extensive and maintainable options is to use Selenium from within test framework such as Ruby On Rails with Rspec and Capybara which enable you to write scripts which can be run headless and against different browsers. This approach has the downside of not showing you the actual screens which might have visual layout issues.

Programming Languages & Frameworks

Languages are supported through drivers with commands from the Selenium API as methods/functions.

Testing frameworks that can be used with Selenium:

C# - Frameworks: NUnit Haskell
Java - Frameworks: JUnit, TestNG
JavaScript
Objective-C
Perl
PHP - Frameworks: Behat + Mink, Yii
Python - Frameworks: unittest, pyunit, py.test, robot framework
R
Ruby - Frameworks: RSpec, Test::Unit

See also:
How can you write tests for Selenium (or similar) which don't fail because of minor or cosmetic changes?

and

Selenium and non technical team members

and in convincing the business to support:

What problem does automated user interface testing solve?

2
  • Thanks for the helpful answer. We are using the Yii framework which does have functionality testing built in which helps with using Selenium. Commented Apr 17, 2015 at 22:03
  • In my experience its key to try to keep your functional testing suite separate from the code your testing. The big challenge here is maintaining the functional suite as new features are developed. The way I have done this is by ensuring that each change includes a functional test suite change to keep things aligned. This in my opinion should be part of a good test or behaviour driven development approach, where a good balance between combined functional and unit testing can be part of the norm for every change. Plus this will build up a nice regression suite for you over time, bonus!
    – Jeremy
    Commented Jul 4, 2016 at 10:39

Not the answer you're looking for? Browse other questions tagged or ask your own question.