Failure/Error: expect(page).to have_selector("li:nth-child(1) > dl:nth-child(6) > dd")
expected to find css "li:nth-child(1) > dl:nth-child(6) > dd" but there were no matches
以上是我的错误。我正在努力寻找一种方法来验证用户登录时登录的日期和时间。我试图验证选择器/xpath/css 是否存在,但似乎找不到匹配项。以下是我尝试进行验证的一些方法,但并不满意。有任何想法吗?
expect(page).to have_selector("li:nth-child(1) > dl:nth-child(6) > dd")
expect(page).to have_xpath("/html/body/main/ul[@class='visitors']/li[1]/dl[6]/dd")
这是我要验证的 Web 应用程序的部分页面源代码。
<ul class='visitors'>
<li>
<dl>
<dt>Title</dt>
<dd></dd>
</dl>
<dl>
<dt>First name</dt>
<dd>John</dd>
</dl>
<dl>
<dt>Last name</dt>
<dd>Doe</dd>
</dl>
<dl>
<dt>Email</dt>
<dd>johndoe@gmail.com</dd>
</dl>
<dl>
<dt>Signed in at</dt>
<dd>April 26, 2021 08:25</dd>
</dl>
</li>