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
Above is my error. I'm struggling to find a way to verify the date and time logged in when a user signs in. I have tried to validate that the selector/xpath/css exist, but it doesn't seem to find a match. Below is some ways I tried to proceed to verify, but it's not happy. Any ideas?
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")
Here is part of the page source from the web application I'm trying to validate.
<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>[email protected]</dd>
</dl>
<dl>
<dt>Signed in at</dt>
<dd>April 26, 2021 08:25</dd>
</dl>
</li>
When you say "verify the date and time logged in" it's unclear whether you're trying to verify a specific date/time or just that one exists. It's also unclear whether you're trying to verify the order of the fields shown, or just verify that the date time field is there somewhere. Assuming you're just trying to verify that a field with a date time exists it could be something like