From: Ahmed A. <asa...@ya...> - 2015-08-24 02:13:19
|
Hi Clinton, >> Did you find my attachments and see the POST requests? Yes I did, but there was no POST request triggered by HtmlUnit with me. I even enabled HttpComponents header logging, and all requests are GET. Please try the below code, which I used. @Test public void testRichFacesFileUpload() throws Exception { final CollectingAlertHandler handler = new CollectingAlertHandler(); try (final WebClient webClient = new WebClient(BrowserVersion.CHROME, "localhost", 8888)){ webClient.setAlertHandler(handler); webClient.setAjaxController(new NicelyResynchronizingAjaxController()); String url = "http://showcase.richfaces.org/richfaces/component-sample.jsf?demo=fileUpload&skin=blueSky"; HtmlPage page = webClient.getPage(url); // choose file to upload HtmlInput htmlInput = (HtmlInput) page.getByXPath("//input[@type='file']").get(0); page = (HtmlPage) htmlInput.setValueAttribute("C:\\use\\chrome.PNG"); // click Upload button HtmlElement element = (HtmlElement) page.getByXPath( "//*[@id='j_idt1245:upload']/div[1]/span[1]/span[2]/span").get( 0); page = (HtmlPage) element.click(); } catch(Exception e) { System.out.println(e.getMessage()); } for (String x : handler.getCollectedAlerts()) { System.err.println(x); } } Ahmed From: "Parham, Clinton" <cp...@bi...> To: Ahmed Ashour <asa...@ya...>; "htm...@li..." <htm...@li...> Sent: Thursday, August 20, 2015 3:15 PM Subject: Re: [Htmlunit-user] RichFaces 4 fileUpload <!--#yiv6103805429 _filtered #yiv6103805429 {font-family:Calibri;panose-1:2 15 5 2 2 2 4 3 2 4;} _filtered #yiv6103805429 {font-family:Tahoma;panose-1:2 11 6 4 3 5 4 4 2 4;} _filtered #yiv6103805429 {font-family:HelveticaNeue;}#yiv6103805429 #yiv6103805429 p.yiv6103805429MsoNormal, #yiv6103805429 li.yiv6103805429MsoNormal, #yiv6103805429 div.yiv6103805429MsoNormal {margin:0in;margin-bottom:.0001pt;font-size:12.0pt;font-family:"Times New Roman", "serif";}#yiv6103805429 a:link, #yiv6103805429 span.yiv6103805429MsoHyperlink {color:blue;text-decoration:underline;}#yiv6103805429 a:visited, #yiv6103805429 span.yiv6103805429MsoHyperlinkFollowed {color:purple;text-decoration:underline;}#yiv6103805429 p.yiv6103805429MsoAcetate, #yiv6103805429 li.yiv6103805429MsoAcetate, #yiv6103805429 div.yiv6103805429MsoAcetate {margin:0in;margin-bottom:.0001pt;font-size:8.0pt;font-family:"Tahoma", "sans-serif";}#yiv6103805429 span.yiv6103805429BalloonTextChar {font-family:"Tahoma", "sans-serif";}#yiv6103805429 p.yiv6103805429msoacetate, #yiv6103805429 li.yiv6103805429msoacetate, #yiv6103805429 div.yiv6103805429msoacetate {margin-right:0in;margin-left:0in;font-size:12.0pt;font-family:"Times New Roman", "serif";}#yiv6103805429 p.yiv6103805429msonormal, #yiv6103805429 li.yiv6103805429msonormal, #yiv6103805429 div.yiv6103805429msonormal {margin-right:0in;margin-left:0in;font-size:12.0pt;font-family:"Times New Roman", "serif";}#yiv6103805429 p.yiv6103805429msonormal1, #yiv6103805429 li.yiv6103805429msonormal1, #yiv6103805429 div.yiv6103805429msonormal1 {margin-right:0in;margin-left:0in;font-size:12.0pt;font-family:"Times New Roman", "serif";}#yiv6103805429 p.yiv6103805429msochpdefault, #yiv6103805429 li.yiv6103805429msochpdefault, #yiv6103805429 div.yiv6103805429msochpdefault {margin-right:0in;margin-left:0in;font-size:12.0pt;font-family:"Times New Roman", "serif";}#yiv6103805429 p.yiv6103805429msonormal2, #yiv6103805429 li.yiv6103805429msonormal2, #yiv6103805429 div.yiv6103805429msonormal2 {margin-right:0in;margin-left:0in;font-size:12.0pt;font-family:"Times New Roman", "serif";}#yiv6103805429 p.yiv6103805429msoacetate1, #yiv6103805429 li.yiv6103805429msoacetate1, #yiv6103805429 div.yiv6103805429msoacetate1 {margin-right:0in;margin-left:0in;font-size:12.0pt;font-family:"Times New Roman", "serif";}#yiv6103805429 p.yiv6103805429msonormal3, #yiv6103805429 li.yiv6103805429msonormal3, #yiv6103805429 div.yiv6103805429msonormal3 {margin-right:0in;margin-left:0in;font-size:12.0pt;font-family:"Times New Roman", "serif";}#yiv6103805429 p.yiv6103805429msonormal11, #yiv6103805429 li.yiv6103805429msonormal11, #yiv6103805429 div.yiv6103805429msonormal11 {margin-right:0in;margin-left:0in;font-size:12.0pt;font-family:"Times New Roman", "serif";}#yiv6103805429 p.yiv6103805429msochpdefault1, #yiv6103805429 li.yiv6103805429msochpdefault1, #yiv6103805429 div.yiv6103805429msochpdefault1 {margin-right:0in;margin-left:0in;font-size:12.0pt;font-family:"Times New Roman", "serif";}#yiv6103805429 p.yiv6103805429msonormal4, #yiv6103805429 li.yiv6103805429msonormal4, #yiv6103805429 div.yiv6103805429msonormal4 {margin:0in;margin-bottom:.0001pt;font-size:12.0pt;font-family:"Times New Roman", "serif";}#yiv6103805429 p.yiv6103805429msoacetate2, #yiv6103805429 li.yiv6103805429msoacetate2, #yiv6103805429 div.yiv6103805429msoacetate2 {margin-right:0in;margin-left:0in;font-size:12.0pt;font-family:"Times New Roman", "serif";}#yiv6103805429 p.yiv6103805429msonormal5, #yiv6103805429 li.yiv6103805429msonormal5, #yiv6103805429 div.yiv6103805429msonormal5 {margin-right:0in;margin-left:0in;font-size:12.0pt;font-family:"Times New Roman", "serif";}#yiv6103805429 p.yiv6103805429msonormal12, #yiv6103805429 li.yiv6103805429msonormal12, #yiv6103805429 div.yiv6103805429msonormal12 {margin-right:0in;margin-left:0in;font-size:12.0pt;font-family:"Times New Roman", "serif";}#yiv6103805429 p.yiv6103805429msochpdefault2, #yiv6103805429 li.yiv6103805429msochpdefault2, #yiv6103805429 div.yiv6103805429msochpdefault2 {margin-right:0in;margin-left:0in;font-size:12.0pt;font-family:"Times New Roman", "serif";}#yiv6103805429 p.yiv6103805429msonormal21, #yiv6103805429 li.yiv6103805429msonormal21, #yiv6103805429 div.yiv6103805429msonormal21 {margin:0in;margin-bottom:.0001pt;font-size:12.0pt;font-family:"Times New Roman", "serif";}#yiv6103805429 p.yiv6103805429msoacetate11, #yiv6103805429 li.yiv6103805429msoacetate11, #yiv6103805429 div.yiv6103805429msoacetate11 {margin:0in;margin-bottom:.0001pt;font-size:8.0pt;font-family:"Times New Roman", "serif";}#yiv6103805429 p.yiv6103805429msonormal31, #yiv6103805429 li.yiv6103805429msonormal31, #yiv6103805429 div.yiv6103805429msonormal31 {margin-right:0in;margin-left:0in;font-size:12.0pt;font-family:"Times New Roman", "serif";}#yiv6103805429 p.yiv6103805429msonormal111, #yiv6103805429 li.yiv6103805429msonormal111, #yiv6103805429 div.yiv6103805429msonormal111 {margin:0in;margin-bottom:.0001pt;font-size:11.0pt;font-family:"Times New Roman", "serif";}#yiv6103805429 p.yiv6103805429msochpdefault11, #yiv6103805429 li.yiv6103805429msochpdefault11, #yiv6103805429 div.yiv6103805429msochpdefault11 {margin-right:0in;margin-left:0in;font-size:10.0pt;font-family:"Times New Roman", "serif";}#yiv6103805429 span.yiv6103805429msohyperlink {}#yiv6103805429 span.yiv6103805429msohyperlinkfollowed {}#yiv6103805429 span.yiv6103805429msohyperlink2 {}#yiv6103805429 span.yiv6103805429msohyperlinkfollowed2 {}#yiv6103805429 span.yiv6103805429msohyperlink11 {}#yiv6103805429 span.yiv6103805429msohyperlinkfollowed11 {}#yiv6103805429 span.yiv6103805429emailstyle1711 {}#yiv6103805429 span.yiv6103805429emailstyle271 {}#yiv6103805429 span.yiv6103805429emailstyle38 {}#yiv6103805429 span.yiv6103805429msohyperlink1 {color:blue;text-decoration:underline;}#yiv6103805429 span.yiv6103805429msohyperlinkfollowed1 {color:purple;text-decoration:underline;}#yiv6103805429 span.yiv6103805429msohyperlink21 {color:blue;text-decoration:underline;}#yiv6103805429 span.yiv6103805429msohyperlinkfollowed21 {color:purple;text-decoration:underline;}#yiv6103805429 span.yiv6103805429msohyperlink111 {color:blue;text-decoration:underline;}#yiv6103805429 span.yiv6103805429msohyperlinkfollowed111 {color:purple;text-decoration:underline;}#yiv6103805429 span.yiv6103805429emailstyle17111 {color:windowtext;}#yiv6103805429 span.yiv6103805429emailstyle2711 {color:#1F497D;}#yiv6103805429 span.yiv6103805429emailstyle381 {color:#1F497D;}#yiv6103805429 span.yiv6103805429EmailStyle56 {font-family:"Calibri", "sans-serif";color:#1F497D;}#yiv6103805429 span.yiv6103805429EmailStyle57 {font-family:"Calibri", "sans-serif";color:#1F497D;}#yiv6103805429 .yiv6103805429MsoChpDefault {font-size:10.0pt;} _filtered #yiv6103805429 {margin:1.0in 1.0in 1.0in 1.0in;}#yiv6103805429 div.yiv6103805429WordSection1 {}-->Hi Ahmed, Did you find my attachments and see the POST requests? Thank you, Clint From: Parham, Clinton Sent: Thursday, August 13, 2015 2:12 PM To: 'Ahmed Ashour'; htm...@li... Subject: RE: [Htmlunit-user] RichFaces 4 fileUpload Hi Ahmed, I did attach three files to my earlier email: FirefoxFileUpload.txt – shows POST that Charles captured for FireFox HTMLUnitFileUpload.txt – shows POST that Charles captured for HTMLUnit HTMLUnitTestCase.java – code to reproduce I see them attached in my Sent Items. Should I send them another way? Also, the id that you have in your code “j_idt1245:upload” sometimes changes on the site when they update it. Today the id is “j_idt498:upload”. Thanks. From: Ahmed Ashour [mailto:asa...@ya...] Sent: Thursday, August 13, 2015 1:44 PM To: htm...@li... Subject: Re: [Htmlunit-user] RichFaces 4 fileUpload Hi again, There are no POST requests by Charles for the below code. Please post your code and provide compared results. Ahmed @Test public void testRichFacesFileUpload() throws Exception { final CollectingAlertHandler handler = new CollectingAlertHandler(); try (final WebClient webClient = new WebClient(BrowserVersion.CHROME, "localhost", 8888)){ webClient.setAlertHandler(handler); webClient.setAjaxController(new NicelyResynchronizingAjaxController()); String url = "http://showcase.richfaces.org/richfaces/component-sample.jsf?demo=fileUpload&skin=blueSky"; HtmlPage page = webClient.getPage(url); // choose file to upload HtmlInput htmlInput = (HtmlInput) page.getByXPath("//input[@type='file']").get(0); page = (HtmlPage) htmlInput.setValueAttribute("C:\\use\\chrome.PNG"); // click Upload button HtmlElement element = (HtmlElement) page.getByXPath( "//*[@id='j_idt1245:upload']/div[1]/span[1]/span[2]/span").get( 0); page = (HtmlPage) element.click(); } catch(Exception e) { System.out.println(e.getMessage()); } for (String x : handler.getCollectedAlerts()) { System.err.println(x); } } |