Skip to content

How to write a Wait or Ensure that "or"s several expectations together? #2309

Answered by jan-molak
perrygoy asked this question in How to... ?
Discussion options

You must be logged in to vote

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 to Check if the results are present, and if they're not - look for the results not found message.

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(

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@perrygoy
Comment options

Answer selected by perrygoy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@serenity-js/core @serenity-js/assertions Screenplay-style assertions library @serenity-js/web Screenplay Pattern APIs for interacting with the Web
2 participants