我正在尝试在页面上查找文本。使用 Selenium 的 Python 代码:
driver.find_element_by_xpath("//span[@ng-bind=''@' + user.username']")
我需要的文本“@bassale”位于页面上:
执行代码时出现错误:
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/