What is UI-Element? , Selenium Notes, Videos, Examples By.www.laxmiroy.blogspot.com/
What is UI-Element?
UI-Element is selenium’s answer to object repository. Those of us who have worked with test automation tools like QTP and WinRunner know what they are. Just to recap object repositories or GUI-Maps are map files where GUI object references are stored. These typically allow you to create logical entities and map them to GUI elements present in your test application. Now in your test script wherever there is a need to refer to a GUI element you can do so using its logical name given in the map file. This allows us to have logical names for ui objects instead of literal locator strings.
UI-Element is supported as a user extension in Selenium IDE and Selenium-RC. Haw-Bin Chai is the creator of this cool feature.The complete documentation of UI-Elements is available here . I know the official doc is a little overwhelming when you read it for the first time. But don't worry we would only be needing a very small part of the stuff that is in there.
Why do we need it?
* Readability: You have semantically meaningful names of elements in your test script rather than having the locators themselves that don’t make much sense. The test script becomes readable and comprehendible to a non-technical person as well.
* Maintainability
+ Single point of update: If the definition of a ui-element changes than you need to make changes at just one central location i.e. in your map file. Against this if you are using literal locators in your test script you would have to edit every instance of that element in your script. This is usually very tedious and error prone.
+ Error checking: ui-map file is JavaScript file that will alert you if there were any syntactical mistakes like ill-formed regular expressions etc.
Below you can see a two versions of a test scenario recorded using IDE. The scenario involves searching for the word 'wikipedia' in google and then searching for the word 'selenium' in the wikipedia search. There are a few 'verify' and 'waitFor' commands thrown in just to make the whole thing look good. Now the first one is without the usage of UI-Elements, just the plain recording and the next one uses UI-Elements. Notice how the script becomes a lot more readable when using UI-Elements.
No comments:
Post a Comment