python-3.x - Python Selenium,在span中查找文本

标签 python-3.x selenium

我正在尝试在页面上查找文本。使用 Selenium 的 Python 代码:

driver.find_element_by_xpath("//span[@ng-bind=''@' + user.username']")

我需要的文本“@bassale”位于页面上:

enter image description here

执行代码时出现错误:

selenium.common.exceptions.InvalidSelectorException: Message: {"errorMessage":"Unable to locate an element with the xpath expression //span[@ng-bind=''@' + user.username'] because of the following error:\nError: INVALID_EXPRESSION_ERR: DOM XPath Exception 51

帮我在页面上找到这段文字。

最佳答案

尝试这样的事情:

driver.find_element_by_xpath("//span[@ng-bind=\"'@' + user.username\"]")

关于python-3.x - Python Selenium,在span中查找文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46347752/

相关文章:

java - 页面对象模型 - 下拉菜单

python - 如何修复 python 中的 "Failed to establish a new connection: [Errno 10061]"错误?

c - 乘以十六进制 > uint32> 返回十六进制

python - 手动提交偏移量到kafka主题的正确方法是什么

python - Python 3 中的 'function' 、 'method' 和 'bound method' 之间有什么区别?

python - 如何使用python在selenium中通过部分id名称查找元素

selenium - 如何使用 junit4 和 selenium webdriver 使用 chrome 运行我的场景

python - 使用 Python 抓取 HTML 信息

python-3.x - FastText 0.9.2 - 召回是 'nan' 但精度是一个数字

sql-server - 如何使用 Azure 机器学习笔记本连接到 SQL Server 和 Azure SQL 数据库?