我想点击“确定”按钮。按钮的HTML如下所示:
**<span class="button-group">
<span id="yui-gen159" class="yui-button yui-push-button alf-primary-button">
<span class="first-child">
<button type="button" id="yui-gen159-button">OK</button>
</span>
</span>
<span id="yui-gen160" class="yui-button yui-push-button default">
<span class="first-child">
<button type="button" id="yui-gen160-button">Cancel</button>
</span>
</span>
</span>**
单击“确定”按钮的python代码是:
def hover(self):
element = driver.find_element_by_link_text("OK")
hov = ActionChains(driver).move_to_element(element)
hov.perform()
WebDriverWait.until(EC.element_to_be_clickable((By.link_text, "OK"))).click()
使用此代码,我的“OK”按钮会高亮显示,但不会被单击。我也尝试了很多其他的方法,但都无法使用
目前没有回答
相关问题 更多 >
编程相关推荐