From: kamala <kam...@gm...> - 2008-09-25 06:19:02
|
Hi , I am using htmlunit2.2 . My webpage contains a link on click of that i get a popup window without url. my code to access title text of popup window is as follow. but i am getting exception. code : HtmlForm frmBatchUpdate = pgCurrent.getFormByName("UpdateMultipleProdsForm"); //click on select link to open FulfillmentSiteList window HtmlAnchor btnSelect = (HtmlAnchor) frmBatchUpdate.getOneHtmlElementByAttribute("a","class","cat_btn_small"); // click on 'select' link pgSearchFFSId = (HtmlPage) btnSelect.click(); // FulfillmentSiteListForm is formname of popup window HtmlForm frmFFSList = pgSearchFFSId.getFormByName("FulfillmentSiteListForm"); Exception as follow when trying to getform "FulfillmentSiteListForm" "com.gargoylesoftware.htmlunit.ElementNotFoundException: elementName=[form] attributeName=[name] attributeValue=[FulfillmentSiteListForm]" Regards Kamala -- View this message in context: http://www.nabble.com/Popup-window-not-recognised-tp19663691p19663691.html Sent from the HtmlUnit - General mailing list archive at Nabble.com. |
From: Rabin A. <ra...@ne...> - 2008-09-25 13:25:57
|
Kamala, Here is a sample example to get the popup window. Hope it will help you import java.net.URL; import java.util.LinkedList; import java.util.List; import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.WebWindow; import com.gargoylesoftware.htmlunit.WebWindowEvent; import com.gargoylesoftware.htmlunit.WebWindowListener; import com.gargoylesoftware.htmlunit.html.HtmlButtonInput; import com.gargoylesoftware.htmlunit.html.HtmlPage; public class PopupTest { // save the pop up window final static LinkedList<WebWindow> windows = new LinkedList<WebWindow>(); // get the main page private static HtmlPage getMainPage(String strUrl) throws Exception { final WebClient webClient = new WebClient(); WebClient.setIgnoreOutsideContent(true); webClient.setThrowExceptionOnScriptError(false); webClient.addWebWindowListener(new WebWindowListener() { public void webWindowClosed(WebWindowEvent event) { } public void webWindowContentChanged(WebWindowEvent event) { } public void webWindowOpened(WebWindowEvent event) { windows.add(event.getWebWindow()); } }); final URL url = new URL(strUrl); return (HtmlPage) webClient.getPage(url); } // get the popup page private static HtmlPage getPopupPage() { WebWindow latestWindow = windows.getLast(); return (HtmlPage) latestWindow.getEnclosedPage(); } public static void main (String [] args) { String strUrl = "http://www.tizag.com/javascriptT/javascriptpopups.php"; try { // get the page and click POP2 button HtmlPage mainPage = getMainPage(strUrl); System.out.println(mainPage.getTitleText()); List popupList = (List) mainPage.getByXPath("//input[@value='POP2!']"); if (popupList.size() == 1) { HtmlButtonInput popup = (HtmlButtonInput) popupList.get(0); popup.click(); } // get the popup window contents if ( windows.size() > 0) { HtmlPage popupPage = getPopupPage(); System.out.println(popupPage.getTitleText()); } } catch(Exception error) { System.err.println(error.toString()); } } } Thanking Sincerely, Rabin Aryal Software Developer NetLert Communications, Inc. 828-418-0023 ext.317 -----Original Message----- From: kamala [mailto:kam...@gm...] Sent: Thursday, September 25, 2008 2:19 AM To: htm...@li... Subject: [Htmlunit-user] Popup window not recognised Hi , I am using htmlunit2.2 . My webpage contains a link on click of that i get a popup window without url. my code to access title text of popup window is as follow. but i am getting exception. code : HtmlForm frmBatchUpdate = pgCurrent.getFormByName("UpdateMultipleProdsForm"); //click on select link to open FulfillmentSiteList window HtmlAnchor btnSelect = (HtmlAnchor) frmBatchUpdate.getOneHtmlElementByAttribute("a","class","cat_btn_small"); // click on 'select' link pgSearchFFSId = (HtmlPage) btnSelect.click(); // FulfillmentSiteListForm is formname of popup window HtmlForm frmFFSList = pgSearchFFSId.getFormByName("FulfillmentSiteListForm"); Exception as follow when trying to getform "FulfillmentSiteListForm" "com.gargoylesoftware.htmlunit.ElementNotFoundException: elementName=[form] attributeName=[name] attributeValue=[FulfillmentSiteListForm]" Regards Kamala -- View this message in context: http://www.nabble.com/Popup-window-not-recognised-tp19663691p19663691.html Sent from the HtmlUnit - General mailing list archive at Nabble.com. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Htmlunit-user mailing list Htm...@li... https://lists.sourceforge.net/lists/listinfo/htmlunit-user |
From: kamala <kam...@gm...> - 2008-09-26 09:20:36
|
Hi Rabin Aryal , Thanks . Its working fine now. Regards Kamala kamala wrote: > > > > I am using htmlunit2.2 . My webpage contains a link on click of that i get > a popup window without url. > > my code to access title text of popup window is as follow. but i am > getting exception. > > code : > > HtmlForm frmBatchUpdate = > pgCurrent.getFormByName("UpdateMultipleProdsForm"); > > //click on select link to open FulfillmentSiteList window > > HtmlAnchor btnSelect = (HtmlAnchor) > frmBatchUpdate.getOneHtmlElementByAttribute("a","class","cat_btn_small"); > > // click on 'select' link > pgSearchFFSId = (HtmlPage) btnSelect.click(); > > // FulfillmentSiteListForm is formname of popup window > > HtmlForm frmFFSList = > pgSearchFFSId.getFormByName("FulfillmentSiteListForm"); > > Exception as follow when trying to getform "FulfillmentSiteListForm" > > "com.gargoylesoftware.htmlunit.ElementNotFoundException: > elementName=[form] attributeName=[name] > attributeValue=[FulfillmentSiteListForm]" > > > Regards > Kamala > -- View this message in context: http://www.nabble.com/Popup-window-not-recognised-tp19663691p19685103.html Sent from the HtmlUnit - General mailing list archive at Nabble.com. |