Search
Display results as :
Advanced Search
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
neppalli72
Posts : 5
Join date : 2012-10-25

Dynamic object identification problem for OK button Empty Dynamic object identification problem for OK button

on Tue Oct 30, 2012 2:16 pm
Hi,

I have a problem in identifying button(OK button) object in my application.

when i see xpath of the object it is showing as below

Code:


//*[@id='ext-gen256'] - first time
//*[@id='ext-gen257'] - next time
//*[@id='ext-gen258'] -next time

HTML code below

<tbody class="x-btn-small x-btn-icon-small-left">
<tr>
<tr>
<td class="x-btn-ml">
<td class="x-btn-mc">
<em class="" unselectable="on">
<button id="ext-gen257" class="x-btn-text" type="button">OK</button>
</em>
</td>
<td class="x-btn-mr">


Kindly help me to resolve this issue.

Thanks
Venkat



Last edited by neppalli72 on Tue Oct 30, 2012 2:17 pm; edited 1 time in total (Reason for editing : code)
avatar
popsha
Amateur
Amateur
Posts : 60
Join date : 2012-04-14

Dynamic object identification problem for OK button Empty Re: Dynamic object identification problem for OK button

on Tue Oct 30, 2012 4:31 pm
hi venkat,

try this and let me know

//button[starts-with(@id, 'ext-gen')]

or

//*[starts-with(@id, 'ext-gen')]
avatar
neppalli72
Posts : 5
Join date : 2012-10-25

Dynamic object identification problem for OK button Empty Re: Dynamic object identification problem for OK button

on Tue Oct 30, 2012 6:50 pm
Hi,

I got finally used below xpath code

"//button[.='OK']"

it is working fine finally.

Popsha thanks for your suggestions Smile
avatar
sakthiveljaganathan
Posts : 6
Join date : 2012-12-07

Dynamic object identification problem for OK button Empty Re: Dynamic object identification problem for OK button

on Mon Dec 10, 2012 4:33 pm
Hi,

The below Xpath code

"//button[.='OK']"

is working fine when i take the data from excel for the First time , but fails for the second time in 'OK' Button.

Kindly suggest a solution for this..

Thanks,
Sakthi
avatar
popsha
Amateur
Amateur
Posts : 60
Join date : 2012-04-14

Dynamic object identification problem for OK button Empty Re: Dynamic object identification problem for OK button

on Wed Dec 12, 2012 2:48 pm
did you tried the xpaths i'd provided?
hope that suits well.
if not let me know in detail
avatar
sakthiveljaganathan
Posts : 6
Join date : 2012-12-07

Dynamic object identification problem for OK button Empty Re: Dynamic object identification problem for OK button

on Wed Dec 19, 2012 6:02 pm
I tried the Xpath but it changes dynamically after every execution.Not working .

Also Tried the followings:

1. wait.Until((d) => { return d.FindElement(By.XPath("id('dialog-confirmcjt2')')")); });
driver.FindElement(By.XPath("//button[.='Ok']")).Click();

2.wait.Until((d) => { return d.FindElement(By.XPath("//button[.='Ok']")); });
driver.FindElement(By.XPath("//button[.='Ok']")).Click();

3.driver.FindElement(By.XPath(".//span[contains(text(),'Ok')]")).Click();

Any solution other than this , let me know.
avatar
popsha
Amateur
Amateur
Posts : 60
Join date : 2012-04-14

Dynamic object identification problem for OK button Empty Re: Dynamic object identification problem for OK button

on Mon Jan 14, 2013 9:55 am
could not reply earlier as i'm quite busy with my projects.

i suppose, my code should work in your case. if not, let me know the error console and your html code for that web element.

Always try finding xpath using id or which is unique unless it work in brittle manner.
avatar
sakthiveljaganathan
Posts : 6
Join date : 2012-12-07

Dynamic object identification problem for OK button Empty Re: Dynamic object identification problem for OK button

on Mon Jan 14, 2013 12:20 pm
Hi Popsha, I used for loop for clicking the OK button where the Xpath is varying like //html/div[12]/div[1]/button.Now its working.

Also how to use the starts-with command for the above xpath //html/div[12]/div[1]/button..where div[12] changes each time.
avatar
popsha
Amateur
Amateur
Posts : 60
Join date : 2012-04-14

Dynamic object identification problem for OK button Empty Re: Dynamic object identification problem for OK button

on Fri Jan 18, 2013 2:10 pm
hi sakthi,

provided xptah is "Absolute xpath", let me know your "Relative Xpath", indicating which one changed dynamically as you did earlier.
so I could pass you with one.
avatar
sakthiveljaganathan
Posts : 6
Join date : 2012-12-07

Dynamic object identification problem for OK button Empty Re: Dynamic object identification problem for OK button

on Fri Jan 18, 2013 3:46 pm
Relative Xpath:

xpath=(//button[@type='button'])[8]
xpath=(//button[@type='button'])[11]
xpath=(//button[@type='button'])[13]
Sponsored content

Dynamic object identification problem for OK button Empty Re: Dynamic object identification problem for OK button

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