Quantcast

Dynamically changing button id how to recognize

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Dynamically changing button id how to recognize

sundru
Hi all kinda new to the selenium scene how do i recognize a button as below which has a dynamic
id changes everytime we hit the page ? the button also does not have a name

<button type="button" class="x-btn-text " id="ext-gen34">Login</button>


currently using
click ext-gen43

but the above is not reliable.

thx
-S
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Dynamically changing button id how to recognize

chobomow
Use Xpath of the button
start from a unique id then follow thru

//unique id/div/etc/etc/button

or use the contain option
click link contain 'login'

sundru wrote
Hi all kinda new to the selenium scene how do i recognize a button as below which has a dynamic
id changes everytime we hit the page ? the button also does not have a name

<button type="button" class="x-btn-text " id="ext-gen34">Login</button>


currently using
click ext-gen43

but the above is not reliable.

thx
-S
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Dynamically changing button id how to recognize

chobomow

chobomow wrote
Use Xpath of the button
start from a unique id then follow thru

//unique id/div/etc/etc/button

or use the contain option
click link contain 'login'

sundru wrote
Hi all kinda new to the selenium scene how do i recognize a button as below which has a dynamic
id changes everytime we hit the page ? the button also does not have a name

<button type="button" class="x-btn-text " id="ext-gen34">Login</button>


currently using
click ext-gen43

but the above is not reliable.

thx
-S
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Dynamically changing button id how to recognize

satheesh.jey
This post was updated on .
I think the unique id might vary for every request and you may not know what that id would be. In this case "//unique id/div/etc/etc/button" might not be useful ?
chobomow wrote
chobomow wrote
Use Xpath of the button start from a unique id then follow thru //unique id/div/etc/etc/button or use the contain option click link contain 'login'
sundru wrote
Hi all kinda new to the selenium scene how do i recognize a button as below which has a dynamic id changes everytime we hit the page ? the button also does not have a name currently using click ext-gen43 but the above is not reliable. thx -S
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Dynamically changing button id how to recognize

chobomow
In reply to this post by sundru
I meant to say unique and static.

given
<button type="button" class="x-btn-text " id="ext-gen34">Login</button>

you can
use
css=button.x-btn-text or
//button[contains(@id, "ext-gen")] or
//unique static/button or
//button[@class, "x-btn-text")]

Feel free to contact me @ arthur_hinh@hotmail.com
for more reading on locator see
http://seleniumhq.org/docs/appendix_locating_techniques.html


sundru wrote
Hi all kinda new to the selenium scene how do i recognize a button as below which has a dynamic
id changes everytime we hit the page ? the button also does not have a name

<button type="button" class="x-btn-text " id="ext-gen34">Login</button>


currently using
click ext-gen43

but the above is not reliable.

thx
-S
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Dynamically changing button id how to recognize

kimchuy
In reply to this post by sundru
I have solution using xpath on selenium

Using a class
//button[contains(@class, 'x-btn-text')]

Using text on the button
//button[contains(text(), "write the text here")]

sundru wrote
Hi all kinda new to the selenium scene how do i recognize a button as below which has a dynamic
id changes everytime we hit the page ? the button also does not have a name

<button type="button" class="x-btn-text " id="ext-gen34">Login</button>


currently using
click ext-gen43

but the above is not reliable.

thx
-S
Loading...