mainFrame

Returns the main frame of the currently loaded web page, if any.

Make sure that the web page is loaded completely before accessing its main frame.