PhantomJS - switchToMainFrame()



The switchToMainFrame () method selects the main frame, i.e., the root window.

Syntax

Its syntax is as follows −

var wpage = require('webpage').create(); 
wpage.switchToMainFrame();

Example

var page = require('webpage').create(); 
page.open('http://localhost/tasks/frames.html', function(status) { 
   page.switchToMainFrame(); 
   console.log(page.frameName); 
});

It will produce the following output.

page2
phantomjs_webpage_module_methods.htm
Advertisements