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
Ethson
V2EX  ›  Python

Python selenium 的 WebElement 如何获取 text?

  •  
  •   Ethson · 2022-09-23 16:45:38 +08:00 · 1725 次点击
    这是一个创建于 573 天前的主题,其中的信息可能已经有所发展或是发生改变。
    browser = webdriver.Chrome()
    browser.get("")
    answers_list = browser.find_elements(By.CLASS_NAME, "List-item")
    print(answers_list[0].text)
    

    selenium version = 4.4.3

    WebElement.text 总是返回 visible text ,对于 invisible text 呢?我找了一下,没找到接口。

    有大兄弟能指教下么?谢谢了。

    4 条回复    2022-09-27 14:13:28 +08:00
    smartwusir007
        1
    smartwusir007  
       2022-09-23 17:23:48 +08:00
    啥是 visible text, 啥是 invisible text ?
    lookStupiToForce
        2
    lookStupiToForce  
       2022-09-23 17:32:42 +08:00
    不懂你说的 invisible text 是啥,但感觉你把 dir(answers_list[0])了之后全试一遍就行......
    Deteriorator
        3
    Deteriorator  
       2022-09-24 20:09:33 +08:00
    那你直接 get attribute 好了
    runningman
        4
    runningman  
       2022-09-27 14:13:28 +08:00
    这是个问题吗
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   932 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 21:40 · PVG 05:40 · LAX 14:40 · JFK 17:40
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.