- neppalli72
- Posts : 5
Join date : 2012-10-25
Dynamic object identification problem for OK button
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
Kindly help me to resolve this issue.
Thanks
Venkat
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
- popshaAmateur
- Posts : 60
Join date : 2012-04-14
Re: Dynamic object identification problem for OK button
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')]
try this and let me know
//button[starts-with(@id, 'ext-gen')]
or
//*[starts-with(@id, 'ext-gen')]
- neppalli72
- Posts : 5
Join date : 2012-10-25
Re: Dynamic object identification problem for OK button
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
I got finally used below xpath code
"//button[.='OK']"
it is working fine finally.
Popsha thanks for your suggestions
- sakthiveljaganathan
- Posts : 6
Join date : 2012-12-07
Re: Dynamic object identification problem for OK button
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
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
- popshaAmateur
- Posts : 60
Join date : 2012-04-14
Re: Dynamic object identification problem for OK button
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
hope that suits well.
if not let me know in detail
- sakthiveljaganathan
- Posts : 6
Join date : 2012-12-07
Re: Dynamic object identification problem for OK button
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.
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.
- popshaAmateur
- Posts : 60
Join date : 2012-04-14
Re: Dynamic object identification problem for OK button
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.
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.
- sakthiveljaganathan
- Posts : 6
Join date : 2012-12-07
Re: Dynamic object identification problem for OK button
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.
Also how to use the starts-with command for the above xpath //html/div[12]/div[1]/button..where div[12] changes each time.
- popshaAmateur
- Posts : 60
Join date : 2012-04-14
Re: Dynamic object identification problem for OK button
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.
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.
- sakthiveljaganathan
- Posts : 6
Join date : 2012-12-07
Re: Dynamic object identification problem for OK button
Fri Jan 18, 2013 3:46 pm
Relative Xpath:
xpath=(//button[@type='button'])[8]
xpath=(//button[@type='button'])[11]
xpath=(//button[@type='button'])[13]
xpath=(//button[@type='button'])[8]
xpath=(//button[@type='button'])[11]
xpath=(//button[@type='button'])[13]
Permissions in this forum:
You cannot reply to topics in this forum