IFrames are separate documents, so you wonβt get their contents included in the HTML code for the main page; you must read them separately.
You can do this using the Selenium select_frame function.
You can access the frame through its name, CSS selector, xpath link, etc., as for other elements.
When you select a frame, you change the Selenium context, so you can access the contents of the frame as if it were the current page.
If you have frames inside frames, you can continue this process through the frame tree.
Obviously, you need a way to return the backup path. Selenium provides this by letting you use the same select_frame function, with either relative=up to move the context to the parent of the current frame, or relative=top to go to the main page in the browser.
Thus, using this function, you can move around the frames on the page.
You cannot access all at once; only one frame can be in the context at once, so you can never make one call to get_html_source and immediately get the entire contents of the frames, but you can move around the frames on the page in your selenium script and get the HTML source for each frame separately.
Hope this helps.
source share