为什么我会因Selenium XPath遇到错误
我正在尝试访问我在网站上可以找到的文本的所有实例。
rows = waitForAllElementsToLoad(By.XPATH, "//td[contains(.,'Jones']")
def waitForAllElementsToLoad(bySelector, name):
try:
element = WebDriverWait(driver, 20).until(
EC.presence_of_all_elements_located((bySelector, name))
)
print("HW")
return element
except:
driver.quit()
print("ERROR!1!")
return
由于某种原因,我的WebDriverWait无法正常工作,并且会引发错误的错误。我将所有导入的东西都输入,然后在Google Chrome Insprip中输入XPath,这也有效。有人可以告诉我我做错了什么吗?
I am trying to access all instances of a piece of text I can find on a website.
rows = waitForAllElementsToLoad(By.XPATH, "//td[contains(.,'Jones']")
def waitForAllElementsToLoad(bySelector, name):
try:
element = WebDriverWait(driver, 20).until(
EC.presence_of_all_elements_located((bySelector, name))
)
print("HW")
return element
except:
driver.quit()
print("ERROR!1!")
return
For some reason my WebDriverWait isn't working and it throws an error which triggers the except. I have everything imported, and I typed in the xpath onto google chrome inspect and that also works. Can someone tell me if I'm doing anything wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论