推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
shiyuu
V2EX  ›  Python

selenium 用 webdriver 点击登录不生效

  •  
  •   shiyuu · Sep 24, 2021 · 3421 views
    This topic created in 1828 days ago, the information mentioned may be changed or developed.
    元素 html 是这样
    <button type="submit" class="elp-material-btn login-btn login-btn-disabled" disabled="">登录</button>

    抄了下面这些
    driver.find_element_by_class_name('elp-material-btn').click()
    driver.find_element_by_class_name('login-btn').click()
    driver.find_element_by_class_name('login-btn-disabled').click()
    driver.find_element_by_class_name('elp-material-btn login-btn login-btn-disabled').click()
    driver.find_element_by_link_text('登录').click()
    driver.find_element_by_xpath('/html/body/section/form/div[4]/button')
    driver.find_element_by_xpath('/html/body/section/form/div[4]')
    driver.find_element_by_css_selector('elp-material-btn').click()
    driver.find_element_by_css_selector('login-btn').click()
    driver.find_element_by_css_selector('login-btn-disabled').click()
    driver.find_element_by_css_selector('elp-material-btn login-btn login-btn-disabled').click()

    最后都提示错误
    selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <button type="submit" class="elp-material-btn login-btn">...</button> is not clickable at point (1024, 706). Other element would receive the click: <section class="container">...</section>
    6 replies  •  2021-11-01 14:17:17 +08:00
    hiwind
        1
    hiwind  
       Sep 24, 2021
    disabled="" 表示被禁用无法点击
    ch2
        2
    ch2  
       Sep 24, 2021
    Other element would receive the click
    Eiden
        3
    Eiden  
       Sep 24, 2021
    真男人就去淦 js
    sa2501
        4
    sa2501  
       Sep 24, 2021
    看提示不是找不到按钮,是点击失败。
    可能有个看不见的东西覆盖了你要点的按钮,那就不用 element.click(),
    用这个:
    ```
    JavascriptExecutor executor;
    executor.executeScript("arguments[0].click();", loginBtn);
    ```
    Vegetable
        5
    Vegetable  
       Sep 24, 2021
    driver.find_element_by_class_name('login-btn-disabled').click()

    这个看起来有一种莫名的幽默感
    这个 button 是 disabled 状态,提示说的也是这个元素是 not clickable 的。
    wzly
        6
    wzly  
       Nov 1, 2021
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   941 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 43ms · UTC 19:16 · PVG 03:16 · LAX 12:16 · JFK 15:16
    ♥ Do have faith in what you're doing.