Share
Go down
imfaus
Active particpant
Active particpant
Posts : 13
Join date : 2012-01-13

Help locating a dynamic locator

on Fri Jan 13, 2012 4:31 am
I am using IDE 1.4.1 It turns out the application i am testing many of the 'locators' change. For example the login page the username input field changed from id="dnn_ctr910_Login_Login_DNN_txtUsername" to id="dnn_ctr633_Login_Login_DNN_txtUsername" as a result it caused the automation to fail. I see there was a post on how to find an element dynamically but it was for a radio button I need it for an input field. I need a way to look for the element where it ends with
Login_Login_DNN_txtUsername I tried to use below in the IDE

storeAttribute
Login_Login_DNN_txtUsername@id
userNameInputfield


Any help would be great. Thanks

Example of HTML source:
freesky
Amateur
Amateur
Posts : 72
Join date : 2011-04-13

Re: Help locating a dynamic locator

on Fri Jan 13, 2012 9:37 am
you can try function 'contains()' of xpath
faramka
Professional
Professional
Posts : 143
Join date : 2011-09-15
Location : Poland

Re: Help locating a dynamic locator

on Fri Jan 13, 2012 2:29 pm
As freesky wrote - use xPath.
imfaus
Active particpant
Active particpant
Posts : 13
Join date : 2012-01-13

Re: Help locating a dynamic locator

on Fri Jan 13, 2012 7:51 pm
Sorry I am not that good with xpath here is what I am using and its failing to work

store
xpath=id('//input[contains(@id, 'Login_Login_DNN_txtPassword')]')
userinputfield



I know the value that the locator will end with each time
Login_Login_DNN_txtPassword knowing this what exactly should the xpath look like?
freesky
Amateur
Amateur
Posts : 72
Join date : 2011-04-13

Re: Help locating a dynamic locator

on Mon Jan 16, 2012 6:55 pm
u can use
type
//input[contains(@id, 'Login_Login_DNN_txtPassword')]
3

if the id of field password alway ends with 'Login_Login_DNN_txtPassword', i think this should work.
imfaus
Active particpant
Active particpant
Posts : 13
Join date : 2012-01-13

Re: Help locating a dynamic locator

on Mon Jan 16, 2012 10:47 pm
Ok this worked thank you so much! I did have two more questions:
1) how would you do this if you wanted to click a link say the id changes dynamically but the link string in the UI stays the same for example, html source is:






I tried to run this in the IDE and if failed
xpath=//a[text()='add']/@href


Secondly How would you do this for a search field again like the example I initially presented where I know the string that the locator will end with
ViewUserManagement_UserCallbackPanel_UserGrid_DXFREditorcol0_I
Below is the html source. I tried to use this in the IDE and it failed




class="dxeEditArea_Default dxeEditAreaSys ">
freesky
Amateur
Amateur
Posts : 72
Join date : 2011-04-13

Re: Help locating a dynamic locator

on Tue Jan 17, 2012 9:03 am
1) for example, if u want to locate this topic, then in ide, it'll look like next :

open http://seleniumforum.forumotion.net/f3-selenium-ide-discussion
click //div[@id='main-content']//a[text()='Help locating a dynamic locator']
Sponsored content

Re: Help locating a dynamic locator

Back to top
Permissions in this forum:
You cannot reply to topics in this forum

Add
click xpath=//input[contains(@id, 'ViewUserManagement_UserCallbackPanel_UserGrid_DXFREditorcol0_I')]