1
1
mirror of https://github.com/aelve/guide.git synced 2024-11-23 12:15:06 +03:00

[tests] Require the selected element to be unique

This commit is contained in:
Artyom 2016-08-24 18:23:43 +03:00
parent 0fa7b6d55c
commit ae0ad75af0

View File

@ -256,8 +256,22 @@ instance ToSelector Selector where
instance ToSelector Text where
toSelector = ByCSS
-- | Ensure that the element is the only element matching the selector.
select :: CanSelect a => a -> WD Element
select x = do
es <- selectAll x
case es of
[] -> expectationFailure
(printf "%s wasn't found on the page" (show x))
>> undefined
[e] -> return e
_ -> expectationFailure
(printf "%s isn't unique on the page" (show x))
>> undefined
-- | Select one of the elements matching the selector.
selectSome :: CanSelect a => a -> WD Element
selectSome x = do
es <- selectAll x
when (null es) $ expectationFailure $
printf "%s wasn't found on the page" (show x)