V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2021-09-24 10:48:53 +08:00 · 2067 次点击
    这是一个创建于 916 天前的主题,其中的信息可能已经有所发展或是发生改变。
    元素 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 条回复    2021-11-01 14:17:17 +08:00
    dejavuwind
        1
    dejavuwind  
       2021-09-24 11:03:53 +08:00
    disabled="" 表示被禁用无法点击
    ch2
        2
    ch2  
       2021-09-24 11:11:56 +08:00
    Other element would receive the click
    Eiden
        3
    Eiden  
       2021-09-24 11:16:24 +08:00
    真男人就去淦 js
    sa2501
        4
    sa2501  
       2021-09-24 11:31:21 +08:00
    看提示不是找不到按钮,是点击失败。
    可能有个看不见的东西覆盖了你要点的按钮,那就不用 element.click(),
    用这个:
    ```
    JavascriptExecutor executor;
    executor.executeScript("arguments[0].click();", loginBtn);
    ```
    Vegetable
        5
    Vegetable  
       2021-09-24 11:35:08 +08:00
    driver.find_element_by_class_name('login-btn-disabled').click()

    这个看起来有一种莫名的幽默感
    这个 button 是 disabled 状态,提示说的也是这个元素是 not clickable 的。
    wzly
        6
    wzly  
       2021-11-01 14:17:17 +08:00
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1635 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 16:51 · PVG 00:51 · LAX 09:51 · JFK 12:51
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.