Cross Frame Access with jQuery

I am researching the use of jQuery for Web application test automation. One of the things I need to do is access HTML elements in one frame from another frame. A search of the Internet yielded several people asking how to do this but no answers. Anyway, after about two hours of work I came up with a solution to the problem. The screenshot below shows a demo in action. The main page has two frames. When a user clicks on the Set Text button in the page in left frame, control is transferred to a jQuery function which places text into the text box control in the right frame. The key lines of code are:
  $(parent.rightFrame.document).contents().find(‘#TextBox1’).val(‘Hello from left frame!’);
Anyway, jQuery is very cool and I should have a Web application test automation article written for MSDN Magazine done in a few weeks.

This entry was posted in Software Test Automation. Bookmark the permalink.