How to access a window or frame's document

LegacyForumLegacyForum Posts: 1,669 ✭✭
edited December 2016 in SOAtest
when chaining an extension tool to a browser testing tool
These examples are intended for use when chaining an Extension tool to a Browser Testing Tool, used in a Web Functional Test.

getDocument is overloaded as follows:
getDocument(); // gets the document for the main window
getDocument(String windowName); // gets the document for the window with the specified window name
getDocument(String windowName, String frameName); // gets the document for a frame within a window

For example, the following code gets the content of a frame titled "mainPane" in the main window. It then uses the document to get the title text for the selected frame.
CODEvar Application =;
var WebBrowserUtil = Packages.webking.api.browser2.WebBrowserUtil;

function getFrameDocument(input, context) {
   var document = input.getDocument("", "mainPane");
   var titles = document.getElementsByTagName("title");
   var title = titles.item(0);
   var value = WebBrowserUtil.getTrimmedText(title);
   Application.showMessage("title: " + value);
   return value;
Sign In or Register to comment.