簡體   English   中英

Python Selenium - 自動點擊登錄網頁不起作用

[英]Python Selenium - Automatic click login to webpage not working

我在這里失去了理智,找不到可能出現的錯誤或缺少什么。

我正在嘗試使用 Python 和 Selenium 自動化登錄過程。 當我進入代碼的每一行時,它可以正常工作。 但是如果我只是按運行並且代碼完成沒有任何問題但它沒有登錄。

當我將 chrome 屏幕保持在如下圖所示的一側時,它會登錄,但當我在運行代碼后不做任何事情時不會登錄。 登錄工作在一邊

這是我點擊按鈕的代碼

try:
    cookies_Button = driver.find_element_by_xpath("//button[@title='Accept Cookies']")
    cookies_Button.click()
    time.sleep(5)
except:
    print("Cookies Button click failed")

try:
    Login_Button = driver.find_element_by_xpath("//input[@name='Login'][@type='button']")
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.NAME,'Login')))
    print("Button is ready")
    #time.sleep(10)
    actions = ActionChains(driver) 
    actions.move_to_element(Login_Button).click().perform()
    time.sleep(30)
except:
    print("Login Button click failed")

關於如何自動登錄的任何幫助將不勝感激。

cookies 產生了問題。 添加 cokkies click 有助於解決問題

try:
    cookies_Button = driver.find_element_by_xpath("//button[@title='Accept Cookies']")
    cookies_Button.click()
    time.sleep(5)
except:
    print("Cookies Button click failed")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM