![](/img/trans.png)
[英]How can I select the “Sort By” element through Selenium Webdriver Python
[英]How Can I wait for an Element will be visible then be clicked in Python Selenium Webdriver?
在odoo中,我編寫了代碼來點擊發送按鈕
browser.find_element_by_xpath("//span[.='Send']").click()
單擊此發送按鈕后,我必須單擊“確認銷售”按鈕,但在運行時它會給出一個錯誤,如元素不可見
我也試過了
webdriver.wait.until(browser.find_element_by_xpath("//span[.='Confirm Sale']"))
但它出現了一個錯誤
AttributeError: 'module' object has no attribute 'wait'
但是點擊發送按鈕后,工作流狀態也從“草稿報價”更改為“報價發送”,所以,如何等待我的webdriver完成所有這些操作,然后點擊“確認銷售”按鈕
我已經宣布我的webdriver是這樣的
def setUp(self):
self.browser = webdriver.Firefox()
browser = self.browser
browser.get("http://localhost:5555")
所以請為我提供准確的代碼
您必須導入webdriver等待模塊。 你可以做類似下面的例子。 在Waits閱讀更多等待
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
wd = webdriver.Chrome(executable_path="your/path/to/chromedriver")
# Access website
wait = WebDriverWait(wd, 10)
confirm = wait.until(EC.element_to_be_clickable((By.XPATH, "//span[.='Confirm Sale']")))
confirm.click()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.