最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】selenium的Python如何获取元素的文本

Python crifan 4073浏览 0评论

折腾:

【已解决】Selenium中使用xpath去查找元素时是否可以设置两种规则

期间,需要去获取元素的文本的值

selenium get text

selenium python get text

SeleniumTwo: 34. Using getText( ) to retrieve any elements Text

结果用getText报错:

    priceText = priceSpanElement.getText()

AttributeError: ‘WebElement’ object has no

java – How to gettext() of an element in Selenium Webdriver – Stack Overflow

难道是:get_text()或gettext()

Selenium with Python — Selenium Python Bindings 2 documentation

4. Locating Elements — Selenium Python Bindings 2 documentation

貌似是:text()

How to get text with selenium web driver in python – Stack Overflow

说是:.text

然后通过:

Python and how to get text from Selenium element WebElement object? – Stack Overflow

Selenium and Python to find elements and text? – Stack Overflow

知道了是:

【总结】

Selenium中用Python获取WebElement的文本值的话,可以直接用element.text

注:

WebElement的其他属性,详见:

前言 · Selenium知识总结

然后接着:

【无法解决】PyCharm中Selenium的WebElement变量后面失去了动态提示

转载请注明:在路上 » 【已解决】selenium的Python如何获取元素的文本

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
83 queries in 0.176 seconds, using 22.06MB memory