c# - Unable to click element XPath -


this element i'm trying reach:

<div class="ui-dialog-buttonpane ui-widget-content ui-helper-clearfix">   <div class="ui-dialog-buttonset">     <button style="background-color: rgb(218, 218, 218);" aria-disabled="false" role="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button">         <span style="background-color: transparent;" class="ui-button-text">ok</span>     </button>   </div> </div> 

this code i'm using:

driver.findelement(by.xpath("xpath=(//span[contains(@class,'ui-button-text')][contains(text(),'ok')]))")).click(); 

i used find element feature of selenium ide using xpath , can find element.

you don't need xpath= part inside expression:

driver.findelement(by.xpath("//span[contains(@class,'ui-button-text')][contains(text(),'ok')])")).click(); 

also, think can stop using contains() , check complete class , text() values:

driver.findelement(by.xpath("//span[@class = 'ui-button-text' , . = 'ok'])")).click(); 

here . refers element's text.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -