Selenium Webdriver python: Element is not currently visible & same class name -


i using selenium in python click button in dialog. try click"ok", keeps getting errors

  1. the buttons show "display:block" in css, cause "element not visible" error
  2. find_element_by_xpath, xpath of element keeps changing
  3. the class names same, how choose "ok" button?

here code

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

thank you:)

if element invisible in dom css { display: none}, {opacity: 0}... etc, , selenium not able see given try wait or time.sleep, instead should use execute_script run javascript trigger desired event, this:

driver.execute_script('document.queryselector("span.ui-button-text").click();') 

Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -