Selenium Testing Dynamic Elements 

Every web page element has an Identifier, a name that can be use to locate the
element. These names can be static – for example, when you enter a search term
into Google, the text field in which you type your query is always named ‘q’.
These names can also be dynamic – generated fresh, new, and unique for every
instance of a web page. For example, some web servers might name a text entry
field ‘q1’ on the first instance of a page, and ‘q2’ on the next instance of the
same page, etc. This means your test script could be looking at a different field
name every time you run the script. Dynamic names are usually on a result page
of some given function.

An example would be a result set of data returned to the user. Suppose each
data result, in, say for example a list of documents, had a unique Identifier
for each specific document. So, for a particular search, the search results
page returns a data set with one set of documents and their correponding
Identifiers. Then, in a different search, the search results page returns
a different data set where each document in the result set uses different
Identifiers.

An example will help. Dynamic content involve UI elements who Identifying
properties change each time you open the page displaying them. For example,

Dynamic HTML of an object might look as:

<input type="checkbox" value="true" id="addForm:_ID74:_ID75:0:_ID79:0:

    checkBox" name="addForm:_ID74:_ID75:0:_ID79:0:checkBox"/>

This is HTML snippet for a check box. Its ID and name
(addForm:_ID74:_ID75:0:_ID79:0:checkBox) are same and both are dynamic
(they will change the next time you open the application).


Author: Pavandeep Puddupakkam on May 2, 2010
Category: Selenium RC, Software Testing
Tags:
Google Webdriver Forum -The Online Community for Google Webdriver and Selenium RC Users and Professionals

Leave a Reply

Last articles