我正在使用Selenium库和python。 在页面上,我得到了多个报价,每个报价都有相同的链接开头https://www.example.com/offer/。。。。 和相同的类,但问题是我找不到包含多个类的元素。它还具有相同的属性“data cy”
我试过了
offerName = driver.find_element_by_xpath("//a[contains(@class, 'marginright5') and contains(@class, 'link') and contains(@class, 'linkWithHash') and contains('detailsLink')]")
但由于这个错误,它不起作用
selenium.common.exceptions.InvalidSelectorException: Message: Given xpath expression "//a[contains(@class, 'marginright5') and contains(@class, 'link') and contains(@class, 'linkWithHash') and contains('detailsLink')]" is invalid: [Exception... "<no message>" nsresult: "0x8060000d (<unknown>)" location: "JS frame :: chrome://marionette/content/element.js :: element.findByXPath :: line 387" data: no]
我怎样才能找到他们
就像错误消息说xpath无效一样, 我可以在最后一个“contains”中看到一个错误
尝试更改此选项:
为此:
相关问题 更多 >
编程相关推荐