Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

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

Help locating a dynamic locator Empty Help locating a dynamic locator

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:
avatar
freesky
Amateur
Amateur
Posts : 72
Join date : 2011-04-13

Help locating a dynamic locator Empty Re: Help locating a dynamic locator

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

Help locating a dynamic locator Empty Re: Help locating a dynamic locator

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

Help locating a dynamic locator Empty Re: Help locating a dynamic locator

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?
avatar
freesky
Amateur
Amateur
Posts : 72
Join date : 2011-04-13

Help locating a dynamic locator Empty Re: Help locating a dynamic locator

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.
avatar
imfaus
Active particpant
Active particpant
Posts : 13
Join date : 2012-01-13

Help locating a dynamic locator Empty Re: Help locating a dynamic locator

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 ">
avatar
freesky
Amateur
Amateur
Posts : 72
Join date : 2011-04-13

Help locating a dynamic locator Empty Re: Help locating a dynamic locator

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 https://seleniumforum.forumotion.net/f3-selenium-ide-discussion
click //div[@id='main-content']//a[text()='Help locating a dynamic locator']
Sponsored content

Help locating a dynamic locator Empty 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')]