Favourite Quote

Every artist was first an amateur. - Ralph Waldo Emerson The more difficulties one has to encounter, within and without, the more significant and the higher in inspiration his life will be. - Horace Bushnell

Saturday, February 26, 2011

Selenium RC UI Mapping

Why should we map the Elements or identifiers or locators in UI?

Imagine that if you have a case with hundreds of input in login field. Now the login text box has been changed to drop down list or the name of the identifier has been changed from Textbox_Login to txt_login.

If we execute our existing test scripts they will fail as they cannot find the locator and making changes in all scripts that involve would be hard.

Hence we map the UI objects & store them in a centralized location for making the script more efficient and maintainable.

So we create a Properties file where we store all the UI objects identifiers & for any further changes we can just tweak this properties file as against all testscripts.

Create the properties file :

Create a file like resLogin.properties and we can assign the UI element as follows:

resuser.firstname = "ctl00_txtFirstName";
resuser.middlename = "ctl00_txtMiddleName";
resuser.lastname = "ctl00_txtLastName";
resuser.loginname = "ctl00_txtLoginName";
resuser.password = "ctl00_txtPassword";


All you have to do now is make a call in your selenium scripts.

For ex :

selenium.type("resuser.firstname","Shabana");
selenium.type("resuser.middlename"," ");
selenium.type("resuser.lastname","K");
selenium.type("resuser.loginname","autouser1");
selenium.type("resuser.password","welcome");

In the above example for any identifiers being changed you have to make changes in the properties file & replace the one highlighted. automationwithselenium.blogspot.com-Google pagerank and Worth

2 comments:

  1. When ever u try to help some one pls try to send the whole detail.

    ReplyDelete
    Replies
    1. Sory.. if i missed to let you know some information.

      If your question is precise i can help

      Delete