完成以下代码,一旦可用,就可以单击该按钮,并可以刷新页面
button = browser.find_elements_by_xpath("//button[contains(@value, 'Refresh Page')]"); //To check button is present on page if (len(button)>0): //And is displayed if button[0].is_displayed(): button[0].click() else: print "button not display" else: print("there is not refresh page button")
要么
// to check the dialog present here "show" is the class which retain by the div once the refresh button get enabled if "show" in browser.find_element_by_id('timeout_dialog').get_attribute('class'): browser.find_element_by_xpath("//button[contains(@value, 'Refresh Page')]").click() else: print "refresh button not displaying"
的 注意 强> :根据python进行语法修正