I am writing automated tests for web applications using Selenium 3.141.59 and Java 8. My general strategy for tracking elements of interest (landmarks & interactive elements) involves setting up a hierarchy of interfaces, each containing one or more By locators and/or subinterfaces, each interface representing an area within the application, (e.g. the login screen.)
The application under test (AUT) is a cloud-based app that makes annoyingly extensive use of IFRAME's. While switchTo() generally serves me well, the only association between an element of interest and its parent IFRAME that I have, at present, is laid out within the test code itself. If I inadvertently fail to precede my wait with the appropriate switchTo(), my element never gets found. Fair enough. To mitigate this problem, I'm trying to improve my metadata by capturing the additional piece of context (parent IFRAME) along with each By locator, to help bulletproof my location process.
My first thought is that instead of defining constants consisting of simple By locators, one might create a composite class, a duple consisting of one field locating the element of interest, and another locating its parent frame.
But before I head blindly down that path, I thought I might seek advice from the community. What are your thoughts/suggestions?