硒找不到元素:直接在div下

时间:2019-03-11 03:04:11

标签: selenium automated-tests

我正在尝试使用xpath从页面中查找特定文本。硒找不到此确切的文本。

这是我尝试使用的代码:

searchresult = self.driver.find_element_by_xpath("//*[contains(text(), 'Sorry, we could not find the book you were looking for.')]")

这是我正在使用的HTML:

<div style="width:100%;padding: 20px;">
    <div class="searchbox">
    </div>
    <div class="vert-spacing-15"></div>

    Sorry, we could not find the book you were looking for. Please try 
    searching for something else.
</div>

0 个答案:

没有答案