从 Element Selenium Python 打印文本

Zetlex DK

我想将这部分打印到控制台。(标记)图像

这是我最后一次尝试:

我上次尝试时遇到此错误:

无法定位元素:

{"method":"xpath","selector":"///*[@id="react-root"]/section/main/div/ul/li[2]/a/span"}

保持在我这个文本的变化。

followers = driver.find_element_by_xpath('//*[@id="react-root"]/section/main/div/ul/li[2]/a/span').GetAttribute("innerHTML")

print("Followers: " + followers)
游轮潘迪

您可以使用以下 xpath :

//a[contains(@href, 'followers')]/span

并且GetAttributeSelenium 中没有任何可用的方法 - Python 绑定。

相反,您可以使用:

followers = driver.find_element_by_xpath("//a[contains(@href, 'followers')]/span").get_attribute("innerHTML")
print("Followers: ", followers)

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Selenium Python:不打印元素文本

Python + Selenium -- 打印出文本

无法从 Webelement Selenium Python 打印文本

Selenium + Python:打印元素的文本属性

打印文本框中的文本 PYTHON Selenium

当element是Python-Selenium中的链接时打印URL

使用Python Selenium遍历表行并打印列文本

Python / Selenium-无法打印所有段落的文本内容

如何在python selenium中打印隐藏文本?

Python / Selenium-在字符之前打印元素的文本

Python Selenium Element Not interactable

Python Selenium文本字段的打印输出值显示为空。该值不打印

Selenium Python通过表循环打印我得到的列值Element不再有效

无法在python中使用Selenium打印browser.find_element_by_xpath

使用 python 循环遍历表行并在 selenium 中打印文本

如何从Google趋势中提取标题/文本并通过Selenium和Python打印它们

如何使用Selenium Webdriver Python中跨度的定位器打印文本?

使用 python 和 selenium 从谷歌搜索打印文本不起作用?

Python Selenium:如何打印链接?

Stopping the program until an element is found [Selenium, Python]

Python Selenium,查找跨度文本

从 <strong> Selenium (Python) 获取文本

Python Selenium Xpath 获取文本

Python Selenium不显示文本

如果 Python Selenium 中存在 element 或 another_element

如何使用 Selenium 和 Python 在分隔行中打印出所有附加有计数器的元素文本

Python selenium 从文本区域获取文本

使用Selenium Python打印特定的Cookie

Python Selenium无法打印整个页面