c# - Unable to click button in popup using webdriver -


i trying click button using selenium webdriver. working fine following xpath

driver.findelement(by.xpath("html/body/div[36]/div[3]/div/button[1]")).click(); 

it clicks button fine if try find using class wont click it

driver.findelement(by.xpath("//div[@class='ui-dialog-buttonset']/button[1]")).click(); 

any idea doing wrong. actual source code follows:-

<div class="ui-dialog-buttonpane ui-widget-content ui-helper-clearfix">      ::before     <div class="ui-dialog-buttonset">         <button class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button" role="button" aria-disabled="false">      <span class="ui-button-text"></span>  </button> <button class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button" role="button" aria-disabled="false">                  <span class="ui-button-text"></span>             </button>         </div>         ::after     </div>  </div> 

i see 2 buttons same class name. try this:

list<webelement> list = driver.findelements(by.cssselector("button[class=\"ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only\"]")); //click on first button list.get(0).click();   

Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -