My basic question was confusing, I write it again. Now it is very clear.
Hello I am trying to navigate the web page using HTMLUnit. I am trying to go to URL - & gt; Enter text in the text box (in frame 1) - & gt; Press Search Button (in Frame 1) - & gt;
HTML page page = webClient.getPage ("http: // someurl.com"); HtmlPage toolbar = (HtmlPage) page.getFrameByName ("Toolbar"). GetEnclosedPage (); // Toolbar Frame HtmlTextInput searchBox = Toolbar GetElementByName ("query"); // text box element search box Set value attribute ("some STRING"); // Fill text box with text list & lt; HtmlElement & gt; Element 1 = (list & lt; HTMLElement & gt;) toolbar .getByXPath (& lt; some XPATH & gt;); // The list of one end element which is the search button HTMLElement element2 = elements1.get (0); // Find the Search button element from the list button = element2.click (); // Click on the "Page" Search button and load a new page I'm searching for "SOME STRING" . When I do this, an additional page comes up (though the page is not refreshed, the URL never refreshes). So now, I click the search button, but the new page is only a webpage in the toolbar frame, not the entire webpage
I want to use additional frames now. So how do I "back out" the current frame and select the new frame?
I found out my test and error.
page = (HtmlPage) searchButton.click (). GetEnclosingWindow () GetTopWindow () GetEnclosedPage (); Page = (HtmlPage) page.getFrameByName ("Frame1"). GetEnclosedPage (); Page = (HtmlPage) page.getFrameByName ("frame2"). GetEnclosedPage (); This works great, hope that I can help some of you.
No comments:
Post a Comment