• Blog
  • En Twitter
  • Aprendiendo
  • Descubriendo
  • Disfrutando
  • Trabajando
  • Creando
    • Fotografías
  • Galerías
    • Ponferrada
  • Vídeos
    • Favoritos
    • Humor
    • Juegos
    • Música
    • Cine

Enlarge Image

sep
5
2011
 1

Software Testing Automation – An START-TO-END example


This is an START-TO-END example of test case automation. The target of this post is to explain ALL the steps I follow to design, develop, test, run and schedule an automated test case.

For this example I will use a very simple Requirement because my goal is not to show who to design test cases, but to automate them.

REQUIREMENT: (example)

In WordPress Dashboard, when an user with “administrator” role logs in, this user will be able to see “Appearance” link, and when clicking on the link,  Themes page is displayed.

In WordPress Dashboard, when an user with “editor” role logs in, this user will NOT be able to see “Appearance” link and will NOT be able to access Themes page.

SUMMARY OF THE EXAMPLE:

1. How to design the test script.

2. How to capture needed web events with Selenium IDE.

3. How to automate the test with RIDE (Robot Framework IDE).

4. How to schedule executions with Jenkins.

1. HOW TO DESIGN THE TEST SCRIPT:

Well, no tricks or secret tips for this. I use paper or a simple word processor (Notepad++ is great!) to design a draft for my test script. The target of this script is to transform given requirements in a serie of steps that can be executed in the system. These steps have to assure compliance with the requirement.

TEST SCRIPT (example)

  • Log in to WordPress with an user with administrator role (admin1)
  • Check “Appearance” link is visible.
  • Click on “Appearance” link.
  • Check Themes page is displayed.
  • Log in to WordPress with an user with editor role (editor1)
  • Check “Appearance” link is not visible.
  • Check that you can NOT access Themes page (typing URL manually)

For sure, many more checks are possible, but we are going to work with these ones only for this example.

2. HOW TO CAPTURE NEEDED WEB EVENTS WITH SELENIUM IDE:

Installation:

  • Download and install Firefox web browser.
  • Download and install Selenium IDE (a Firefox plugin).

Capture events and actions:

  • Open Firefox.  Go to “Tools > Selenium IDE“. Selenium IDE will run in a new window.
  • Go back to Firefox window and execute all the steps needed in your web page/application. For our example, we will go to our WordPress page, log in and click on “Appearance” link. Selenium IDE is capturing them. When finish, you will see something like this in Selenium IDE window:
  • Go to “File > Save Test Case as”. Select type “HTML” and choose a name, for example, admin1.html. Save it. You can export the Test Cases to many other formats. As we are going to use RIDE for automation, html format is ok. If you open the saved html file in your web browser you will see something like this:

This is all we need for now from Selenium IDE. We will use this table later on.

3. HOW TO AUTOMATE THE TEST WITH RIDE (Robot Framework IDE).

3.1. Installation: you can use this guide to install RIDE with AutoIT and Selenium libraries.

3.2. Creation of the Test Project tree:

  • Open RIDE. Go to “File > New project”. Type a name for the new project (f.e. “Example Project”), select “Directory” and desired format (we use always TSV format (Tab Separated Values) for all test projects, suites and cases. This format is friendlier is you need to parse these files later). Press “Ok”.
  • Right click on project name and click on “Add Suite”. Type a name (f.e. “Example Suite”), select “Directory” (because we want to create new test suites in) and desired format. Press “Ok”.
  • Right click on the Suite and click on “Add Suite” again. Type a name (f.e. “Access to Themes page”), select “File” (because we want to create new test cases in) and desired formar. Press “Ok”.
  • Right click on this last Suite and click on “New Test Case“. Type a name (f.e. “administrator”) a press “Ok”.
  • Select this last created test case (f.e. “administrator”). Click on “Edit” tab and write something in the table. (f.e. “Comment | Your comment here”) and click on “Save All” button.

WARNING: It is very important you write this initial step in the new test case. If not, NOTHING WILL BE SAVED.

3.3. Adding libraries:

  • You can add libraries to Projects, Suites or Test Cases. For our example, we’re going to add Selenium and AutoIT libraries to our test suite file. When working with a real project, if there are certain libraries you use in a few test cases, I recommend you to add them only to the suites are going to use them.
  • Select the test suite in the tree (f.e. Access to “Themes page”), go to “Edit” tab. Click on “Add Library” button. Type “SeleniumLibrary” and press “Ok”.
  • Do the same again but type “AutoItLibrary” and press “Ok”.
  • Remember you can use this guide to install RIDE with AutoIT and Selenium libraries.

Now, we can use Selenium and AutoIT keyword in our Test Cases, so we can use recorded Selenium IDE script in RIDE.

3.4. Writing test cases in RIDE:

  • Select test case (f.e. “administrator”) and go to “Edit” tab. Copy recorded script from Selenium IDE (point 2) and paste in the table. Something like this:

Now, we have to modify and complete the test case.  We are going to use only a few of the hundred of keywords we can use. These links can be very useful for you:

  • Robot Framework test libraries documentation (all of them)
  • AutoIT library documentacion (v1.1)
  • Selenium library documentation (v2.7)
  • Selenium API documentation (v1.0)

For our example, I have completed the first test case and check it works, here you have the script with some useful (I hope) comments:

  • To execute the test case, go to “Run” tab, select the desire one/s and press “Start” button.
  • After every execution you can see detailed information about it by pressing “Report” and “Log” buttons:

Ok, now it’s time for the second test case. Notice that in this case we are going to check that we do NOT have access to an URL and that we can NOT see a link. Negative test cases are very common so managing errors during test execution is very important. I hope this example helps you to start. Here it is:

NOTE: At this point, (in our real enviroments) we synchronize the new developed test suites to our Subversion server, using Tortoise SVN windows client.


4. HOW TO SCHEDULE EXECUTIONS WITH HUDSON:

Environment: in this example, we are going to use a Windows XP Virtual machine with Internet Explorer 8 to execute these test cases. We have configured this machine as a node of our Jenkins server (you can read this previous post to know how to do it). We use a Jenkins server with Robot Framework Plugin installed.

  • Go to Jenkins and click on “New job“:
  • Enter a name for the job an select “Build multi-configuration project“. Click on “Ok“.
  • Enter a description for the new job.
  • We use Subversion, so we enter here the URL to the directory where test suites are. If not using Subversion just ignore this step.
  • Go to “Configuration Matrix” section and click on “Add axis > Slave“
  • Select the desire machine/s for launching your test suites.
  • Go to “Build” section and click on “Add build step“. Select “Execute Windows batch command“:
  • Enter pybot command to execute your test suites:

In our example:

pybot –outputdir logs –include ready Example_suite.tsv

If you are NOT using Subversion you will have to give absolute path to your test suites:

pybot –outputdir logs –include ready Z:testdirExample_suite.tsv

See all pybot options in the Robot Framework documentation.

  • Configure Robot Framework plugin options:
  • You can setup other options in the new job, as email notification, scheduled executions…. When done, click on “Save“.
  • Now, we have a new job ready to be scheduled in our Jenkins Dashboard. Just click on the “play” button to schedule.
  • If all is well done, build results will be correct.
  • We can access to Robot Framework results and logs from the Build results.

 

Comment for Software Testing Automation – An START-TO-END example


Blojo Reloaded » Deploying an Automation environment for Software Testing
January 30, 2012, 12:39 pm

[...] you have an Start-to-End example of Test Automation. Hope it helps! Twittear !function(d,s,id){var [...]


Reply



Leave A Reply





  Cancel Reply

  • Categorías

    • Aprendiendo (44)
    • Blojo (152)
    • Creando (2)
    • Descubriendo (2)
    • Disfrutando (4)
    • Trabajando (10)





Blojo v3.4 | Proudly Powered by Camelot Fields