python
  • selenium
  • webdriver
  • odoo
  • 2015-09-04 110 views 3 likes 
    3

    在odoo我已經寫代碼,點擊發送按鈕即如何等待元素將會顯示,然後在Python Selenium Webdriver中單擊?

    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' 
    
    012錯誤

    我堅持2個圖像爲 before Send button image - it's a wizard After send button , wizard will be closed & then have to click on confirm sale button

    但這裏發送之後按鈕點擊後,工作流狀態也從「報價草案」爲「報價已發送」改變的話,我怎麼能等到我的webdriver爲所有這些事情做好&然後點擊「確認出售」按鈕

    我宣佈我的webdriver這樣

    def setUp(self): 
        self.browser = webdriver.Firefox() 
        browser = self.browser 
        browser.get("http://localhost:5555") 
    

    所以請給我提供Ë xact代碼

    +0

    [硒waitForElement]的可能重複(http://stackoverflow.com/questions/7781792/selenium-waitforelement) – JeffC

    回答

    3

    您必須導入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 
    wait = WebDriverWait(wd, 10) 
    confirm = wait.until(EC.element_to_be_clickable((By.XPATH, "//span[.='Confirm Sale']"))) 
    confirm.click() 
    
    +0

    ķ感謝,我會嘗試這個 –

    +1

    WD沒有定義 – oxidworks

    +0

    wd是webdriver的實例 – Wingman4l7

    相關問題