I am writing a Selenium testcase for a webpage which has multiple frames and WebElements. My goal is to get a specific WebElement by xpath without knowing anything about the iframes before starting the testcase.
What would be the best way to identify the iframe in which the WebElement I am searching for is located?
I created a pseudocode function which might work, but I am not sure if it's the best way:
- Create a list with all iFrames found via the html-frame tag
- Iterate through every list
- set the driver focus to the list element
- search for the WebElement I want to have
- If WebElement is not null return it
Is there any better way to solve this problem?