How to write a Wait
or Ensure
that "or"s several expectations together?
#2309
-
I have a search bar that will either display search results or a "results not found" message. I'm trying to write a task which will commit a search and wait for one of those two things to happen. How can i write a theActor.attemptsTo(
Ensure.thatAtLeastOneOf(
(Search.searchResult(), isPresent()),
(Search.noResultsMessage(), isPresent()),
)
) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
It seems like you can either get a Something along those lines: import { Check } from '@serenty-js/core'
import { Ensure. isPresent } from '@serenity-js/assertions'
import { Text } from '@serenity-js/web'
const VerifySearchResults = () =>
Task.where(`#actor verifies search results`,
Check.whether(Search.noResultsMessage(), isPresent())
.andIfSo(
Ensure.that(Text.of(Search.noResultsMessage()), equals('results not found'))
)
.otherwise(
Ensure.that(Search.searchResult(), isPresent()),
)
) Hope this helps! |
Beta Was this translation helpful? Give feedback.
It seems like you can either get a
results not found
message, or a search result, but never both simultaneously. If so, I'd suggest using a conditional statement toCheck
if the results are present, and if they're not - look for theresults not found
message.Something along those lines: