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
neppalli72
Posts : 5
Join date : 2012-10-25

Dynamic object identification problem for OK button Empty 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

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

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

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

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

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

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

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

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

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

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