How to select nested iframes

Hi all,

I have been experimenting in using the browser library. The application that I need to test is using nested iframes.

For my solution I wish to make use of the Set Selector Prefix keyword provided by the Browser library so that depending on the screen I’m using I can get into the right iframes. This will be called in the Test setup and in the Test case itself I’ll click on a button which is in the nested iframe.

For this keyword I have been struggling to get the right prefix.
Right now I tried the following:
Set Selector Prefix iframe[title=“Frame1title”] >>> iframe[title=“Frame2title”] >>>

The problem now however is that it converts the first iframe selection into an actual framelocator from Playwright and the second one into a normal locator which fails the tests.

If anyone could help me out how to solve this problem I greatly appreciate it :)!

Hi Jordy

sometime i use Test generator | Playwright

for example you can use command:
npx playwright codegen https://www.google.com

It can give you a search direction to define an xpath/css, for example for an iframe.

Greetz,
Joost

Hey Joost,

Thanks for your reply! I will look into it :wink:
I have tried using the Record Selector Keyword from the Browser library, but without any success. Do you know if this Test Generator is also possible to run through the use of RF?

Nested locators should at least work without selector prefix. But if selector prefix doesn’t work for nested frames, then that sounds like a bug. Please raise an issue

1 Like