elixir-wallaby/wallaby

Various functions do not raise StaleReferenceError

jonleighton opened this issue · 0 comments

I have a test where asynchronous behaviour makes it possible that I will find an element, but then when I call Wallaby.Element.hover/1 on it, the element has gone.

I was hoping to handle this scenario by rescuing Wallaby.StaleReferenceError. However, I get this instead:

     ** (CaseClauseError) no case clause matching: {:error, :stale_reference}

This is the current implementation of hover/1:

def hover(%__MODULE__{driver: driver} = element) do
case driver.hover(element) do
{:ok, _} ->
element
end
end

Clearly, it needs to handle the {:error, :stale_reference} case and raise a StaleReferenceError.

When I looked at the code for Wallaby.Element and Wallaby.Browser, I realised that various other functions also only handle the {:ok, ...} case. So it looks like there's a need to deal with this more generally rather than just in the hover/1 function.