My Blog List

Tuesday, October 12, 2010

Selenium - Regular Expressions, Dynamic Objects

Hi Guys,


I am using selenium RC with Visual Studio 2010 IDE  and created tests.
Also i am using Selenium RC with Eclipse...


Here i am listed out some ideas in identifying dynamic objects.
Take your Object id looks like "ctl00_MainEntry_AreaCreationControl_AreaGridView_ctl12_AreaNameFooterTextBox"
Here ctl12 is the part which is changing part based on which row / session...But you want to enter the value irrespective of row position..


Here you have to use regular expressions

  1. //input[Contains(@id,'ctl00_MainEntry_AreaCreationControl_AreaGridView_ctl') and Contains(@id,'_AreaNameFooterTextBox')]
  2. //input[@id,RegExp:'ctl00_MainEntry_AreaCreationControl_AreaGridView_ctl??_AreaNameFooterTextBox']
  3. //input[@id,glob:'ctl00_MainEntry_AreaCreationControl_AreaGridView_ctl*_AreaNameFooterTextBox']
  4. //*@id,glob:'ctl00_MainEntry_AreaCreationControl_AreaGridView_ctl*_AreaNameFooterTextBox']

If all the above methods are not working for you, then try these...

  1. //input[contains(@name,concat("starttext","_","middle","_")) and contains(@name,"endtext")]
  2. css=input[id$='starttext'] --- this means starts-with
  3. css=input[id^='endtext'] --- this means ends-with
  4. input[starts-with(@id='starttext')] --- this means starts-with
  5. input[ends-with(@id='endtext')] --- this means ends-with
Hope any one of the above solution will work....

வாழ்க வளமுடன்....