I want to get an element's id attribute that is inside of an iframe through Java. How do I access an element inside of an iframe in Java?
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It only takes a minute to sign up.Sign up to join this community
In my experience the simplest way to manipulate elements inside of an iframe with web automation is to treat the iframe src URL as a separate page and call the driver to visit that URL instead of the parent page. From the example in the screenshot, I would have an automated step that would visit the URL in the
src attribute of
iframe#ComposeRteEditor_surface... (the actual
src attribute wasn't visible in the screenshot), then I would call the appropriate step or
findElement() function as normal.
You should try out the TestProject test recorder which can locate elements within iFrames, so you’ll be able to inspect elements and their attributes easily.