I try to run fin function but for some reason I get back nil. The item I search for have to be there, how can I get the html to see what went wrong?
How to get html page in wallaby
5k Views Asked by Yoni S AtThere are 2 best solutions below

I don't know if this is your problem or not, but when I tried wallaby on this html:
<p class="results"><div class="green">That's all folks!</div></p>
with this find()
:
find(css(".results", count: 1))
I got the error:
** (Wallaby.QueryError) Expected to find 1, visible element that matched the css '.results' but 0, visible elements were found.
But, if I change the html to this:
<div class="results"><span class="green">That's all folks!</span></div>
and I use the same find()
(which by the way does not return a list, so don't follow that with List.first()
), then wallaby does find the element. According to the html5
spec, you can't put a div tag inside a p tag, and the opening div
tag will cause a browser to close the p tag, like this:
HERE
|
V
<p class="results"></p><div class="green">That's all folks!</div></p>
I don't think wallaby is able to parse the illegal html and find the p tag. You might try running your html through an html validator before trying wallaby on it.
I have two helper functions that receive the wallaby session.
The first prints the visible text to STDOUT:
The second function prints the complete HTML page source to STDOUT:
By returning the session these functions can be used between the usual wallaby queries/assertions:
Another helpful function is Wallaby.Browser.take_screenshot/2