推荐学习书目
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 · 3106 views
    This topic created in 1696 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   ·   Solana   ·   3050 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 50ms · UTC 09:40 · PVG 17:40 · LAX 02:40 · JFK 05:40
    ♥ Do have faith in what you're doing.