From: Mehrdad R. <rez...@ya...> - 2008-02-07 19:59:05
|
Hi Everyone, I've been running into great difficult loading a page which includes iframes. I've been reading all the posts regarding problems with iframe, but they all seem to date to 2006 or early 2007; so, I'm hoping that someone has already found a solution. In my code, based on whether I disable JavaScript or enable it two different errors happen (note that for my situation,I do without JavaScript if it solves my problem). My code has nothing complicated, it just gets a page, and that's where the erorr happens. And also as you will see from the log that I have included below, these are all just iframes which display some adds and if I could somehow just ignore them or not download them, it would be great. Here's my code: ______________________ wc = new WebClient(BrowserVersion.INTERNET_EXPLORER_6_0); wc.setJavaScriptEnabled(true); wc.setCookiesEnabled(true); wc.setThrowExceptionOnScriptError(false); wc.setRedirectEnabled(true); wc.setRefreshHandler(new ThreadedRefreshHandler()); DefaultJSDialogWindowHandler jsPopupHanlder = new DefaultJSDialogWindowHandler(); wc.setAlertHandler(jsPopupHanlder); wc.setConfirmHandler(jsPopupHanlder); wc.setPromptHandler(jsPopupHanlder); HtmlPage loginPage = null; loginPage = (HtmlPage) wc.getPage("http://my.monster.com/Login.aspx"); _____________________ If I enable the Javascript, only one iframe of one of the ads is loaded onto the page. But if I disable the JavaScript, then I get a NullPointerException and the log below (Note that I have included only the part of the log file which is relevent in order to make reading it easy, but I do have the longer version of the log. ____________________________ [06 Feb 2008 22:15:04}] [DEBUG] [CLASS: com.gargoylesoftware.htmlunit.WebClient] "Get page for window named 'AdFrame_1_MasterPage1:HeaderContent:Header_Default:BannerAd1', using We bRequestSettings[<url="about:blank", SubmitMethod[name=get], EncodingType[name=application/x-www-for m-urlencoded], [], {}, null>]" ============================ [06 Feb 2008 22:15:21}] [DEBUG] [CLASS: com.gargoylesoftware.htmlunit.WebClient] "Get page for window named 'AdFrame_1_MasterPage1:BodyContent:RightOfLoginAd', using WebRequestSett ings[<url="about:blank", SubmitMethod[name=get], EncodingType[name=application/x-www-form-urlencoded ], [], {}, null>]" ============================ [06 Feb 2008 22:15:52}] [DEBUG] [CLASS: com.gargoylesoftware.htmlunit.WebClient] "Get page for window named 'AdFrame_1_MasterPage1:HeaderContent:Header_Default:BannerAd1', using We bRequestSettings[http://ads.monster.com/html.ng/site=m ons&affiliate=mons&app=cc&size=728x90&pp=1&path=/Channels/NMONS/login.aspx&dcpc=&ge=-1&tileid=9186' + parent.segQS );", SubmitMethod[name=get], EncodingType[name=application/x-www-form-urlencoded], [] , {Referer=http://my.monster.com/Login.aspx}, null>]" ============================ java.lang.NullPointerException at com.gargoylesoftware.htmlunit.WebClient.makeWebResponseForJavaScriptUrl(WebClient.java:1331) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:327) at com.gargoylesoftware.htmlunit.html.BaseFrame.loadInnerPageIfPossible(BaseFrame.java:135) at com.gargoylesoftware.htmlunit.html.BaseFrame.loadInnerPage(BaseFrame.java:108) at com.gargoylesoftware.htmlunit.html.HtmlPage.loadFrames(HtmlPage.java:1497) at com.gargoylesoftware.htmlunit.html.HtmlPage.initialize(HtmlPage.java:147) at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:453) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:343) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:397) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:384) ____________________________ Note that the page includes only two iframes and it seems that the frame called AdFrame_1_MasterPage1:HeaderContent:Header_Default:BannerAd1 is loaded a first time with no problem, and then it is loaded a second time and that's when the page loading runs intotrouble. I appreciate it if anyone could give me a feed back as to how to solve this problem. Any suggestion would be greatly appreciated. Thanks, Orod ____________________________________________________________________________________ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping |