折腾:
【已解决】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的其他属性,详见:
然后接着:
【无法解决】PyCharm中Selenium的WebElement变量后面失去了动态提示
转载请注明:在路上 » 【已解决】selenium的Python如何获取元素的文本