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
- the buttons show "display:block" in css, cause "element not visible" error
- find_element_by_xpath, xpath of element keeps changing
- 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
Post a Comment