Skip to content

How to perform an interaction after switching to an iFrame? #2338

Discussion options

You must be logged in to vote

Hi @ChandanHackerrank, if you have a look at the examples in the Switch.to(..) API docs, you'll notice that they follow this pattern:

 await actorCalled('Francesca')
   .attemptsTo(
     Switch.to(LoginForm.iframe).and(                                          // <-- notice the "and"
       Enter.theValue('francesca@example.org').into(LoginForm.usernameField()),
       Enter.theValue('correct-horse-battery-staple').into(LoginForm.passwordField()),
       Click.on(LoginForm.submitButton()),
     )
   )

The idea is that Switch.to(iframe).and(activities) receives a sequence of activities and then automatically switches back when the last one completes.

Does this help?

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by jan-molak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@serenity-js/web Screenplay Pattern APIs for interacting with the Web
2 participants
Converted from issue

This discussion was converted from issue #2321 on April 21, 2024 22:06.