You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(6) |
Jul
(17) |
Aug
(18) |
Sep
(22) |
Oct
(16) |
Nov
(6) |
Dec
(11) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(11) |
Feb
(10) |
Mar
(34) |
Apr
(26) |
May
(6) |
Jun
(22) |
Jul
(14) |
Aug
(4) |
Sep
(47) |
Oct
(69) |
Nov
(23) |
Dec
(21) |
2005 |
Jan
(53) |
Feb
(33) |
Mar
(92) |
Apr
(65) |
May
(63) |
Jun
(57) |
Jul
(43) |
Aug
(132) |
Sep
(61) |
Oct
(75) |
Nov
(60) |
Dec
(130) |
2006 |
Jan
(74) |
Feb
(87) |
Mar
(101) |
Apr
(58) |
May
(54) |
Jun
(42) |
Jul
(31) |
Aug
(67) |
Sep
(61) |
Oct
(71) |
Nov
(28) |
Dec
(58) |
2007 |
Jan
(53) |
Feb
(50) |
Mar
(96) |
Apr
(66) |
May
(55) |
Jun
(130) |
Jul
(99) |
Aug
(115) |
Sep
(37) |
Oct
(78) |
Nov
(24) |
Dec
(70) |
2008 |
Jan
(94) |
Feb
(85) |
Mar
(197) |
Apr
(274) |
May
(119) |
Jun
(143) |
Jul
(193) |
Aug
(99) |
Sep
(160) |
Oct
(120) |
Nov
(178) |
Dec
(109) |
2009 |
Jan
(238) |
Feb
(169) |
Mar
(115) |
Apr
(109) |
May
(131) |
Jun
(167) |
Jul
(144) |
Aug
(193) |
Sep
(155) |
Oct
(154) |
Nov
(97) |
Dec
(127) |
2010 |
Jan
(108) |
Feb
(127) |
Mar
(176) |
Apr
(113) |
May
(130) |
Jun
(200) |
Jul
(115) |
Aug
(80) |
Sep
(92) |
Oct
(101) |
Nov
(124) |
Dec
(53) |
2011 |
Jan
(67) |
Feb
(144) |
Mar
(88) |
Apr
(60) |
May
(89) |
Jun
(54) |
Jul
(68) |
Aug
(81) |
Sep
(48) |
Oct
(40) |
Nov
(10) |
Dec
(20) |
2012 |
Jan
(21) |
Feb
(28) |
Mar
(17) |
Apr
(35) |
May
(41) |
Jun
(44) |
Jul
(68) |
Aug
(67) |
Sep
(89) |
Oct
(58) |
Nov
(47) |
Dec
(56) |
2013 |
Jan
(49) |
Feb
(28) |
Mar
(46) |
Apr
(31) |
May
(28) |
Jun
(37) |
Jul
(34) |
Aug
(52) |
Sep
(42) |
Oct
(108) |
Nov
(59) |
Dec
(56) |
2014 |
Jan
(41) |
Feb
(72) |
Mar
(46) |
Apr
(21) |
May
(19) |
Jun
(17) |
Jul
(15) |
Aug
(40) |
Sep
(11) |
Oct
(3) |
Nov
(5) |
Dec
(31) |
2015 |
Jan
(11) |
Feb
(12) |
Mar
(19) |
Apr
(19) |
May
(38) |
Jun
(54) |
Jul
(14) |
Aug
(42) |
Sep
(14) |
Oct
(16) |
Nov
(26) |
Dec
(14) |
2016 |
Jan
(3) |
Feb
(1) |
Mar
(24) |
Apr
(5) |
May
(15) |
Jun
(14) |
Jul
(33) |
Aug
(19) |
Sep
(8) |
Oct
(10) |
Nov
|
Dec
(2) |
2017 |
Jan
(16) |
Feb
(12) |
Mar
(23) |
Apr
(8) |
May
(11) |
Jun
(20) |
Jul
(21) |
Aug
(20) |
Sep
|
Oct
(6) |
Nov
(9) |
Dec
(2) |
2018 |
Jan
(7) |
Feb
(5) |
Mar
(6) |
Apr
(5) |
May
(1) |
Jun
(2) |
Jul
(2) |
Aug
|
Sep
(4) |
Oct
(3) |
Nov
|
Dec
(4) |
2019 |
Jan
(2) |
Feb
(2) |
Mar
(3) |
Apr
(4) |
May
|
Jun
(4) |
Jul
(9) |
Aug
(2) |
Sep
|
Oct
(4) |
Nov
(1) |
Dec
(7) |
2020 |
Jan
(2) |
Feb
(6) |
Mar
(9) |
Apr
(1) |
May
(1) |
Jun
(15) |
Jul
(1) |
Aug
(1) |
Sep
(2) |
Oct
(6) |
Nov
(3) |
Dec
(5) |
2021 |
Jan
(3) |
Feb
(1) |
Mar
(2) |
Apr
(1) |
May
|
Jun
(1) |
Jul
(1) |
Aug
(3) |
Sep
(1) |
Oct
|
Nov
(1) |
Dec
|
2022 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(2) |
Jun
(1) |
Jul
(4) |
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(6) |
2025 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: beshoo <be...@gm...> - 2017-08-16 23:47:23
|
The code : package likePack; import java.io.IOException; import java.net.MalformedURLException; import com.gargoylesoftware.htmlunit.BrowserVersion; import com.gargoylesoftware.htmlunit.DefaultCssErrorHandler; import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException; import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.WebClientOptions; import com.gargoylesoftware.htmlunit.html.HtmlPage; public class doLike { /** * @param args * @throws IOException * @throws MalformedURLException * @throws FailingHttpStatusCodeException */ public static void main(String[] args) throws FailingHttpStatusCodeException, MalformedURLException, IOException { java.util.logging.Logger.getLogger("com.gargoylesoftware").setLevel(java.util.logging.Level.OFF); String url = "https://www.instagram.com/p/BXlXngWBeFv/"; final WebClient webClient = new WebClient(BrowserVersion.CHROME); final HtmlPage htmlPage = (HtmlPage) webClient.getPage(url); WebClientOptions options = webClient.getOptions(); options.setJavaScriptEnabled(true); options.setCssEnabled(true); int statusCode = htmlPage.getWebResponse().getStatusCode(); String statusMessage = htmlPage.getWebResponse().getStatusMessage(); String responseHeader = htmlPage.getWebResponse().getResponseHeaderValue("Date"); String contentType = htmlPage.getWebResponse().getContentType(); long loadTime = htmlPage.getWebResponse().getLoadTime(); String content = htmlPage.getWebResponse().getContentAsString(); System.out.println("Status Code is: " + statusCode); System.out.println("Status Message is: " + statusMessage); System.out.println("Response Header Date: " + responseHeader); System.out.println("Content Type is: " + contentType); System.out.println("Load Time: " + loadTime); //System.out.println("\n\nContent is:\n\n" + content); } } Errors ---------------------------- Aug 17, 2017 1:47:00 AM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify WARNING: Obsolete content type encountered: 'text/javascript'. Aug 17, 2017 1:47:02 AM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify WARNING: Obsolete content type encountered: 'text/javascript'. Exception in thread "main" ======= EXCEPTION START ======== EcmaError: lineNumber=[20] column=[0] lineSource=[<no source>] name=[TypeError] sourceName=[ https://www.instagram.com/static/bundles/en_US_Commons.js/dee1f534a69b.js] message=[TypeError: public java.lang.Object net.sourceforge.htmlunit.corejs.javascript.NativeError$ProtoProps.getStackTraceLimit(net.sourceforge.htmlunit.corejs.javascript.Scriptable) is not a function, it is function. ( https://www.instagram.com/static/bundles/en_US_Commons.js/dee1f534a69b.js#20 )] com.gargoylesoftware.htmlunit.ScriptException: TypeError: public java.lang.Object net.sourceforge.htmlunit.corejs.javascript.NativeError$ProtoProps.getStackTraceLimit(net.sourceforge.htmlunit.corejs.javascript.Scriptable) is not a function, it is function. ( https://www.instagram.com/static/bundles/en_US_Commons.js/dee1f534a69b.js#20 ) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:894) at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:637) at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:518) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:774) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:750) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:102) at com.gargoylesoftware.htmlunit.html.HtmlPage.loadExternalJavaScriptFile(HtmlPage.java:991) at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:366) at com.gargoylesoftware.htmlunit.html.HtmlScript$2.execute(HtmlScript.java:247) at com.gargoylesoftware.htmlunit.html.HtmlScript.onAllChildrenAddedToPage(HtmlScript.java:268) at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:800) at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:756) at net.sourceforge.htmlunit.cyberneko.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1236) at net.sourceforge.htmlunit.cyberneko.HTMLTagBalancer.endElement(HTMLTagBalancer.java:1136) at net.sourceforge.htmlunit.cyberneko.filters.DefaultFilter.endElement(DefaultFilter.java:226) at net.sourceforge.htmlunit.cyberneko.filters.NamespaceBinder.endElement(NamespaceBinder.java:345) at net.sourceforge.htmlunit.cyberneko.HTMLScanner$ContentScanner.scanEndElement(HTMLScanner.java:3178) at net.sourceforge.htmlunit.cyberneko.HTMLScanner$ContentScanner.scan(HTMLScanner.java:2141) at net.sourceforge.htmlunit.cyberneko.HTMLScanner.scanDocument(HTMLScanner.java:945) at net.sourceforge.htmlunit.cyberneko.HTMLConfiguration.parse(HTMLConfiguration.java:521) at net.sourceforge.htmlunit.cyberneko.HTMLConfiguration.parse(HTMLConfiguration.java:472) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:999) at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:250) at com.gargoylesoftware.htmlunit.html.HTMLParser.parseHtml(HTMLParser.java:192) at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:272) at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:160) at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:522) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:396) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:313) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:461) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:446) at likePack.doLike.main(doLike.java:25) Caused by: net.sourceforge.htmlunit.corejs.javascript.EcmaError: TypeError: public java.lang.Object net.sourceforge.htmlunit.corejs.javascript.NativeError$ProtoProps.getStackTraceLimit(net.sourceforge.htmlunit.corejs.javascript.Scriptable) is not a function, it is function. ( https://www.instagram.com/static/bundles/en_US_Commons.js/dee1f534a69b.js#20 ) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3915) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3899) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3924) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3940) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3991) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3980) at net.sourceforge.htmlunit.corejs.javascript.ScriptableObject.checkPropertyDefinition(ScriptableObject.java:2019) at net.sourceforge.htmlunit.corejs.javascript.ScriptableObject.defineOwnProperty(ScriptableObject.java:1936) at net.sourceforge.htmlunit.corejs.javascript.IdScriptableObject.defineOwnProperty(IdScriptableObject.java:714) at net.sourceforge.htmlunit.corejs.javascript.NativeObject.execIdCall(NativeObject.java:449) at net.sourceforge.htmlunit.corejs.javascript.IdFunctionObject.call(IdFunctionObject.java:94) at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1546) at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:800) at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:105) at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:416) at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:322) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3264) at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.exec(InterpretedFunction.java:115) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$3.doRun(JavaScriptEngine.java:765) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:879) ... 33 more Enclosed exception: net.sourceforge.htmlunit.corejs.javascript.EcmaError: TypeError: public java.lang.Object net.sourceforge.htmlunit.corejs.javascript.NativeError$ProtoProps.getStackTraceLimit(net.sourceforge.htmlunit.corejs.javascript.Scriptable) is not a function, it is function. ( https://www.instagram.com/static/bundles/en_US_Commons.js/dee1f534a69b.js#20 ) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3915) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3899) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3924) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3940) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3991) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3980) at net.sourceforge.htmlunit.corejs.javascript.ScriptableObject.checkPropertyDefinition(ScriptableObject.java:2019) at net.sourceforge.htmlunit.corejs.javascript.ScriptableObject.defineOwnProperty(ScriptableObject.java:1936) at net.sourceforge.htmlunit.corejs.javascript.IdScriptableObject.defineOwnProperty(IdScriptableObject.java:714) at net.sourceforge.htmlunit.corejs.javascript.NativeObject.execIdCall(NativeObject.java:449) at net.sourceforge.htmlunit.corejs.javascript.IdFunctionObject.call(IdFunctionObject.java:94) at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1546) at script( https://www.instagram.com/static/bundles/en_US_Commons.js/dee1f534a69b.js:20 ) at script( https://www.instagram.com/static/bundles/en_US_Commons.js/dee1f534a69b.js:20 ) at script.t( https://www.instagram.com/static/bundles/en_US_Commons.js/dee1f534a69b.js:1) at script( https://www.instagram.com/static/bundles/en_US_Commons.js/dee1f534a69b.js:20 ) at script.t( https://www.instagram.com/static/bundles/en_US_Commons.js/dee1f534a69b.js:1) at script( https://www.instagram.com/static/bundles/en_US_Commons.js/dee1f534a69b.js:20 ) at script.t( https://www.instagram.com/static/bundles/en_US_Commons.js/dee1f534a69b.js:1) at script( https://www.instagram.com/static/bundles/en_US_Commons.js/dee1f534a69b.js:24 ) at script.t( https://www.instagram.com/static/bundles/en_US_Commons.js/dee1f534a69b.js:1) at script( https://www.instagram.com/static/bundles/en_US_Commons.js/dee1f534a69b.js:20 ) at script( https://www.instagram.com/static/bundles/en_US_Commons.js/dee1f534a69b.js:20 ) at script.t( https://www.instagram.com/static/bundles/en_US_Commons.js/dee1f534a69b.js:1) at script( https://www.instagram.com/static/bundles/en_US_Commons.js/dee1f534a69b.js:6) at script.t( https://www.instagram.com/static/bundles/en_US_Commons.js/dee1f534a69b.js:1) at script( https://www.instagram.com/static/bundles/en_US_Commons.js/dee1f534a69b.js:24 ) at script.t( https://www.instagram.com/static/bundles/en_US_Commons.js/dee1f534a69b.js:1) at script( https://www.instagram.com/static/bundles/en_US_Commons.js/dee1f534a69b.js:24 ) at script( https://www.instagram.com/static/bundles/en_US_Commons.js/dee1f534a69b.js:24 ) at script.t( https://www.instagram.com/static/bundles/en_US_Commons.js/dee1f534a69b.js:1) at script( https://www.instagram.com/static/bundles/en_US_PostPage.js/ae28cc90e815.js:1 ) at script.t( https://www.instagram.com/static/bundles/en_US_Commons.js/dee1f534a69b.js:1) at script( https://www.instagram.com/static/bundles/en_US_Commons.js/dee1f534a69b.js:1) at script( https://www.instagram.com/static/bundles/en_US_PostPage.js/ae28cc90e815.js:1 ) at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:800) at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:105) at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:416) at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:322) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3264) at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.exec(InterpretedFunction.java:115) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$3.doRun(JavaScriptEngine.java:765) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:879) at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:637) at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:518) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:774) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:750) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:102) at com.gargoylesoftware.htmlunit.html.HtmlPage.loadExternalJavaScriptFile(HtmlPage.java:991) at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:366) at com.gargoylesoftware.htmlunit.html.HtmlScript$2.execute(HtmlScript.java:247) at com.gargoylesoftware.htmlunit.html.HtmlScript.onAllChildrenAddedToPage(HtmlScript.java:268) at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:800) at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:756) at net.sourceforge.htmlunit.cyberneko.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1236) at net.sourceforge.htmlunit.cyberneko.HTMLTagBalancer.endElement(HTMLTagBalancer.java:1136) at net.sourceforge.htmlunit.cyberneko.filters.DefaultFilter.endElement(DefaultFilter.java:226) at net.sourceforge.htmlunit.cyberneko.filters.NamespaceBinder.endElement(NamespaceBinder.java:345) at net.sourceforge.htmlunit.cyberneko.HTMLScanner$ContentScanner.scanEndElement(HTMLScanner.java:3178) at net.sourceforge.htmlunit.cyberneko.HTMLScanner$ContentScanner.scan(HTMLScanner.java:2141) at net.sourceforge.htmlunit.cyberneko.HTMLScanner.scanDocument(HTMLScanner.java:945) at net.sourceforge.htmlunit.cyberneko.HTMLConfiguration.parse(HTMLConfiguration.java:521) at net.sourceforge.htmlunit.cyberneko.HTMLConfiguration.parse(HTMLConfiguration.java:472) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:999) at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:250) at com.gargoylesoftware.htmlunit.html.HTMLParser.parseHtml(HTMLParser.java:192) at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:272) at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:160) at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:522) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:396) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:313) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:461) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:446) at likePack.doLike.main(doLike.java:25) ======= EXCEPTION END ======== |
From: José R. | I. S.L. <jr...@id...> - 2017-08-11 11:39:30
|
Great suggestion. Thanks a lot! El 11 ago. 2017 10:47 a. m., "Albu Gmail" <alb...@gm...> escribió: > Not a specific answer to your question but generally it's a good idea to > use htmlunitscripter Firefox extension to have a first idea of what sort of > code to write for a specific action. > > With it you can record your action and retrieve a code sequence by using > htmlunit. I used it very often and it saved me a lot of time. > > > Le 10/08/2017 à 02:13, Guang Chao a écrit : > > > > On Thu, Aug 10, 2017 at 12:58 AM, José Román | Idiria S.L. < > jr...@id...> wrote: > >> Hi, >> >> The web page I am working with has a javascript mechanism to attach some >> files (images). The thing is that I cannot understand how to do it. There >> are to methods; a) with direct drag & drop (which I understand is not >> possible under HTMLUnit), b) through selection dialog. The thing is that I >> don't know how to: >> >> 1.- Open the selection dialog (or simulate it). >> 2.- Make JS process the selected files. >> >> The thing is that this is the first time I have to deal woth >> HTMLUnit+Javascript and I am too new to understand how to invoke things >> from Java to Javascript. >> >> It is clear the "upload-all" button does start the submission but I >> cannot see how Javascript behaves when dropping an image. If I could >> perhaps I could understand mechanics behind and imagine how to do things by >> myself... Is there a way to make a "step-by-step" debugging with this JS >> code? >> >> Here you are the code of interest for this problem: >> >> <td class="main"> >> >> <script src="https://static.milanuncios.com/js/fotos/dropzone.4.2.0. >> min.js" type="text/javascript"></script> >> <script src="https://static.milanuncios.com/js/fotos/exif.js" >> type="text/javascript"></script> >> <script src="https://static.milanuncios.com/js/fotos/dropzone-exif- >> extension.js" type="text/javascript"></script> >> <link rel="stylesheet" href="https://static.milanunci >> os.com/css/fotos/dropzone.min.css"> >> >> <script type="text/javascript"> >> function ver(id) { >> document.getElementById(id).style.position = 'absolute'; >> document.getElementById(id).style.display = 'inline'; >> document.getElementById(id).style.visibility = "visible"; >> document.getElementById(id).style.zIndex = '10000'; >> } >> >> Dropzone.options.photoUploader = { >> init: function() { >> var myDropzone = this; >> this.__photoId = 0; >> this.__uploadingPhotos = false; >> this.__isPhotoUploadDone = false; >> this.__errorMessagePrevious = ""; >> >> this.on("thumbnail", function(file){ >> ExifExtension.applyRotation(file); >> }); >> >> this.on("success", function() { >> if(this.__uploadingPhotos) >> this.processQueue(); >> }); >> >> this.options.url = function(files) { >> if (files.length !== 1) { >> alert("Error interno 5690, por favor intentalo >> más tarde"); >> return; >> } >> >> var localPhotoId = ++myDropzone.__photoId; >> >> return >> "/images/upload-image-auth.php?&idanuncio=239851259&clave= >> MldFNw%3D%3D&numfoto="+localPhotoId; >> }; >> >> this.on("processing", function() { >> ver('espera'); >> document.getElementById('upload-all').disabled = >> true; >> }); >> >> this.on("drop", function() { >> this.__errorMessagePrevious = ""; >> }); >> >> this.on("error", function(file, errorMessage) { >> console.log("error: ", errorMessage); >> if (file.status == "error") { >> if (!file.accepted) { >> this.removeFile(file); >> } else { >> errorMessage = this.options.dictResponseError >> ; >> } >> if (errorMessage != this.__errorMessagePrevious) { >> this.__errorMessagePrevious = errorMessage; >> alert(errorMessage); >> } >> } >> if(this.__uploadingPhotos) >> this.processQueue(); >> }); >> >> this.on("queuecomplete", function() { >> this.__isPhotoUploadDone = true; >> window.location = 'http://www.milanuncios.com/pu >> blicado/?idanuncio=239851259&contra=2WE7'; >> }); >> >> var submitButton = document.getElementById("upload-all"); >> submitButton.addEventListener("click", function() { >> myDropzone.__uploadingPhotos = true; >> if (myDropzone.getQueuedFiles().length == 0) { >> myDropzone.emit("queuecomplete", ""); >> } >> else { >> ver('espera'); >> myDropzone.processQueue(); >> } >> }); >> >> var dropArea = document.getElementById("dropArea"); >> dropArea.addEventListener("click", function() { >> // Clean all the previous error messages >> myDropzone.__errorMessagePrevious = ""; >> }); >> }, >> paramName: "uploadFile1", >> parallelUploads: 1, >> maxFiles: 9, >> uploadMultiple: false, >> autoProcessQueue: false, // Prevents Dropzone from uploading >> dropped files immediately >> addRemoveLinks: true, >> maxThumbnailFilesize: 5, >> maxFilesize: 5, >> thumbnailWidth: 100, >> thumbnailHeight: 100, >> imageWidth: 800, >> imageHeight: 800, >> acceptedFiles: "image/jpeg, image/gif ,image/png", >> imageQuality: 0.8, >> dictDefaultMessage: "<strong>Arrastra tus fotos aquí <br/> o >> <br/> selecciónalas de tu equipo</strong><div class=\"btnAddPhoto\">Añadir >> fotos</div>", >> dictFallbackMessage: "Tu navegador no soporta arrastrar fotos >> directamente.", >> dictFallbackText: "Utiliza el método antiguo para subir >> fotos.", >> dictFileTooBig: "La fotos es demasiado grande.", >> dictInvalidFileType: "Formato no permitido. Asegúrate que tus >> fotos son JPG, JPEG, GIF o PNG.", >> dictResponseError: "Error al subir tus fotos. Por favor, >> inténtalo de nuevo más tarde.", >> dictCancelUpload: "Cancelar", >> dictCancelUploadConfirmation: "¿Estás seguro que deseas >> cancelar la subida?", >> dictRemoveFile: "Eliminar", >> dictRemoveFileConfirmation: "¿Estás seguro que deseas >> eliminar esta foto?", >> dictMaxFilesExceeded: "No puedes subir más de 9 fotos." >> }; >> >> window.onbeforeunload = function() { >> if (Dropzone && Dropzone.instances[0] && >> !Dropzone.instances[0].__isPhotoUploadDone) { >> return "¿Realmente quieres irte sin subir tus fotos?"; >> } >> }; >> </script> >> >> <div id="dropArea"> >> <form action="/images/upload-image-auth.php" >> method="post" class="dropzone dz-clickable" drop-zone="" id="photoUploader" >> enctype="multipart/form-data"><div class="dz-default >> dz-message"><span><strong>Arrastra tus fotos aquí <br> o <br> >> selecciónalas de tu equipo</strong><div class="btnAddPhoto">Añadir >> fotos</div></span></div></form> >> </div> >> >> <div class="uploadBtnBox"> >> <button id="upload-all" class="uploadBtn">Finalizar >> publicación</button> >> </div> >> </div> >> </div> >> >> >> > Working with JavaScript is case to case basis to make it work. When I > work with Selenium before, I need to change to different drivers on which > one will work for a specific site. Its really tricky. > > >> >> -- >> >> >> * José Román Bilbao Castro* >> >> Ingeniero Consultor >> +34 901009188 >> >> *jr...@id... <jr...@id...> **http://idiria.com >> <http://www.idiria.com/>* <*http:// <http://%20%20/>idiria.com/ >> <http://idiria.com/>*> >> >> -- >> Idiria Sociedad Limitada - Aviso legal >> >> Este mensaje, su contenido y cualquier fichero transmitido con él está >> dirigido únicamente a su destinatario y es confidencial. Por ello, se >> informa a quien lo reciba por error ó tenga conocimiento del mismo sin ser >> su destinatario, que la información contenida en él es reservada y su uso >> no autorizado, por lo que en tal caso le rogamos nos lo comunique por la >> misma vía o por teléfono (+ 34 690207492), así como que se abstenga de >> reproducir el mensaje mediante cualquier medio o remitirlo o entregarlo a >> otra persona, procediendo a su borrado de manera inmediata. >> >> Idiria Sociedad Limitada se reserva las acciones legales que le >> correspondan contra todo tercero que acceda de forma ilegítima al >> contenido de cualquier mensaje externo procedente del mismo. >> >> Para información y consultas visite nuestra web http://www.idiria.com >> >> >> >> Idiria Sociedad Limitada - Disclaimer >> This message, its content and any file attached thereto is for the >> intended recipient only and is confidential. If you have received this >> e-mail in error or had access to it, you should note that the information >> in it is private and any use thereof is unauthorised. In such an event >> please notify us by e-mail or by telephone (+ 34 690207492). Any >> reproduction of this e-mail by whatsoever means and any transmission or >> dissemination thereof to other persons is prohibited. It should be deleted >> immediately from your system. >> >> Idiria Sociedad Limitada reserves the right to take legal action against >> any persons unlawfully gaining access to the content of any external >> message it has emitted. >> >> For additional information, please visit our website >> http://www.idiria.com >> >> >> >> ------------------------------------------------------------ >> ------------------ >> Check out the vibrant tech community on one of the world's most >> engaging tech sites, Slashdot.org! http://sdm.link/slashdot >> _______________________________________________ >> Htmlunit-user mailing list >> Htm...@li... >> https://lists.sourceforge.net/lists/listinfo/htmlunit-user >> >> > > > -- > Guang > <http://javadevnotes.com/java-string-split-space-or-whitespace-examples> > > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > > > > _______________________________________________ > Htmlunit-user mailing lis...@li...https://lists.sourceforge.net/lists/listinfo/htmlunit-user > > > > ------------------------------------------------------------ > ------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > > |
From: jp l. <jp....@gm...> - 2017-08-11 08:59:13
|
Hi There, I am trying to reach a recaptcha image ... but I can't. Any ideas? try (final WebClient webClient = new WebClient(BrowserVersion.getDefault())) { final HtmlPage home = webClient.getPage("http://www.bcra.gov.ar/BCRAyVos/Situacion_Crediticia_CUIT_CUIL.asp"); final HtmlImage captchaImg = home.getFormByName("form").getFirstByXPath("//*[@id=\"recaptcha_challenge_image\"]"); } captchaImg is null .. thanks in advance ! |
From: José R. | I. S.L. <jr...@id...> - 2017-08-10 17:51:40
|
Cannot do it from the Sourceforge web (no privileges given by administrator)... 2017-08-10 19:46 GMT+02:00 Ronald Brill <rb...@rb...>: > Right, seems the method is missing at the moment. Please open an issue.... > > RBRi > > On Thu, 10 Aug 2017 18:46:22 +0200 José Román | Idiria S.L. wrote: > > > >Well it seems I though it was done too soon. It fails here: > > > > File fileToUpload = new File("C:\firma.jpg"); > > HtmlFileInput fileUploader = (HtmlFileInput) > >currentPage.getFirstByXPath("//input[@type='file']"); > > > > fileUploader.setFiles(fileToUpload); --> This causes the exception > > > >GRAVE: Job run failed with unexpected RuntimeException: TypeError: Cannot > >find function readAsDataURL in object [object FileReader]. ( > >https://static.milanuncios.com/js/fotos/dropzone.4.2.0.min.js#1) > >======= EXCEPTION START ======== > >EcmaError: lineNumber=[1] column=[0] lineSource=[ function () {] > >name=[TypeError] sourceName=[ > >https://static.milanuncios.com/js/fotos/dropzone.4.2.0.min.js] > >message=[TypeError: Cannot find function readAsDataURL in object [object > >FileReader]. ( > >https://static.milanuncios.com/js/fotos/dropzone.4.2.0.min.js#1)] > >com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot find > >function readAsDataURL in object [object FileReader]. ( > >https://static.milanuncios.com/js/fotos/dropzone.4.2.0.min.js#1) > >at > >com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$ > HtmlUnitContextAction.run(JavaScriptEngine.java:894) > >at net.sourceforge.htmlunit.corejs.javascript.Context. > call(Context.java:637) > >at > >net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call( > ContextFactory.java:518) > >at > >com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction( > JavaScriptEngine.java:823) > >at > >com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction( > JavaScriptEngine.java:795) > >at > >com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunction( > HtmlPage.java:2504) > >at > >com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunction( > HtmlPage.java:2497) > >at > >com.gargoylesoftware.htmlunit.javascript.background. > JavaScriptFunctionJob.runJavaScript(JavaScriptFunctionJob.java:52) > >at > >com.gargoylesoftware.htmlunit.javascript.background. > JavaScriptExecutionJob.run(JavaScriptExecutionJob.java:102) > >at > >com.gargoylesoftware.htmlunit.javascript.background. > JavaScriptJobManagerImpl.runSingleJob(JavaScriptJobManagerImpl.java:424) > >at > >com.gargoylesoftware.htmlunit.javascript.background. > DefaultJavaScriptExecutor.run(DefaultJavaScriptExecutor.java:155) > >at java.lang.Thread.run(Unknown Source) > >Caused by: net.sourceforge.htmlunit.corejs.javascript.EcmaError: > TypeError: > >Cannot find function readAsDataURL in object [object FileReader]. ( > >https://static.milanuncios.com/js/fotos/dropzone.4.2.0.min.js#1) > >at > >net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError( > ScriptRuntime.java:3915) > >at > >net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError( > ScriptRuntime.java:3899) > >at > >net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError( > ScriptRuntime.java:3924) > >at > >net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError2( > ScriptRuntime.java:3940) > >at > >net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime. > notFunctionError(ScriptRuntime.java:4007) > >at > >net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime. > getPropFunctionAndThisHelper(ScriptRuntime.java:2402) > >at > >net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime. > getPropFunctionAndThis(ScriptRuntime.java:2384) > >at > >net.sourceforge.htmlunit.corejs.javascript.Interpreter. > interpretLoop(Interpreter.java:1348) > >at > >net.sourceforge.htmlunit.corejs.javascript.Interpreter. > interpret(Interpreter.java:800) > >at > >net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call( > InterpretedFunction.java:105) > >at > >net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall( > ContextFactory.java:416) > >at > >com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory. > doTopCall(HtmlUnitContextFactory.java:322) > >at > >net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall( > ScriptRuntime.java:3264) > >at > >com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$4.doRun( > JavaScriptEngine.java:816) > >at > >com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$ > HtmlUnitContextAction.run(JavaScriptEngine.java:879) > >.... 11 more > >Enclosed exception: > >net.sourceforge.htmlunit.corejs.javascript.EcmaError: TypeError: Cannot > >find function readAsDataURL in object [object FileReader]. ( > >https://static.milanuncios.com/js/fotos/dropzone.4.2.0.min.js#1) > >at > >net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError( > ScriptRuntime.java:3915) > >at > >net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError( > ScriptRuntime.java:3899) > >at > >net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError( > ScriptRuntime.java:3924) > >at > >net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError2( > ScriptRuntime.java:3940) > >at > >net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime. > notFunctionError(ScriptRuntime.java:4007) > >at > >net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime. > getPropFunctionAndThisHelper(ScriptRuntime.java:2402) > >at > >net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime. > getPropFunctionAndThis(ScriptRuntime.java:2384) > >at > >net.sourceforge.htmlunit.corejs.javascript.Interpreter. > interpretLoop(Interpreter.java:1348) > >at script(https://static.milanuncios.com/js/fotos/dropzone.4.2.0.min.js:1 > ) > >at script(https://static.milanuncios.com/js/fotos/dropzone.4.2.0.min.js:1 > ) > >at script(https://static.milanuncios.com/js/fotos/dropzone.4.2.0.min.js:1 > ) > >at > >net.sourceforge.htmlunit.corejs.javascript.Interpreter. > interpret(Interpreter.java:800) > >at > >net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call( > InterpretedFunction.java:105) > >at > >net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall( > ContextFactory.java:416) > >at > >com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory. > doTopCall(HtmlUnitContextFactory.java:322) > >at > >net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall( > ScriptRuntime.java:3264) > >at > >com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$4.doRun( > JavaScriptEngine.java:816) > >at > >com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$ > HtmlUnitContextAction.run(JavaScriptEngine.java:879) > >at net.sourceforge.htmlunit.corejs.javascript.Context. > call(Context.java:637) > >at > >net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call( > ContextFactory.java:518) > >at > >com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction( > JavaScriptEngine.java:823) > >at > >com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction( > JavaScriptEngine.java:795) > >at > >com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunction( > HtmlPage.java:2504) > >at > >com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunction( > HtmlPage.java:2497) > >at > >com.gargoylesoftware.htmlunit.javascript.background. > JavaScriptFunctionJob.runJavaScript(JavaScriptFunctionJob.java:52) > >at > >com.gargoylesoftware.htmlunit.javascript.background. > JavaScriptExecutionJob.run(JavaScriptExecutionJob.java:102) > >at > >com.gargoylesoftware.htmlunit.javascript.background. > JavaScriptJobManagerImpl.runSingleJob(JavaScriptJobManagerImpl.java:424) > >at > >com.gargoylesoftware.htmlunit.javascript.background. > DefaultJavaScriptExecutor.run(DefaultJavaScriptExecutor.java:155) > >at java.lang.Thread.run(Unknown Source) > >== CALLING JAVASCRIPT == > > function () { > > return a._processThumbnailQueue(); > > } > >======= EXCEPTION END ======== > > > > > > > > > > > > > >2017-08-10 9:26 GMT+02:00 Ronald Brill <rb...@rb...>: > > > >> On Wed, 9 Aug 2017 18:58:31 +0200 José Román | Idiria S.L. wrote: > >> > > >> >1.- Open the selection dialog (or simulate it). > >> >2.- Make JS process the selected files. > >> > > >> Without have access to the real page an answer is not that simple. > >> > >> >1.- Open the selection dialog (or simulate it). > >> Usuall there is a input control with type 'file' somewhere on the page. > >> This is more or less the only way to add files to a form to upload them. > >> You have to find that control > >> and use setValueAttribute with the absolute path of the file. > >> > >> >2.- Make JS process the selected files. > >> As always there is nothing special - there is no need to deal with the > js > >> itselt. Simply do the same you do in the real browser e.g. click the > submit > >> button. HtmlUnit tries to do > >> exactyl the same js processing as real browsers. > >> > >> > >> RBRi > >> -------------------------- > >> WETATOR > >> Smart web application testing > >> http://www.wetator.org > >> > >> ------------------------------------------------------------ > >> ------------------ > >> Check out the vibrant tech community on one of the world's most > >> engaging tech sites, Slashdot.org! http://sdm.link/slashdot > >> _______________________________________________ > >> Htmlunit-user mailing list > >> Htm...@li... > >> https://lists.sourceforge.net/lists/listinfo/htmlunit-user > >> > > > > > > > > -- *José Román Bilbao Castro* Ingeniero Consultor +34 901009188 *jr...@id... <jr...@id...>**http://idiria.com <http://www.idiria.com/>* <*http:// <http://%20%20/>idiria.com/ <http://idiria.com/>*> -- Idiria Sociedad Limitada - Aviso legal Este mensaje, su contenido y cualquier fichero transmitido con él está dirigido únicamente a su destinatario y es confidencial. Por ello, se informa a quien lo reciba por error ó tenga conocimiento del mismo sin ser su destinatario, que la información contenida en él es reservada y su uso no autorizado, por lo que en tal caso le rogamos nos lo comunique por la misma vía o por teléfono (+ 34 690207492), así como que se abstenga de reproducir el mensaje mediante cualquier medio o remitirlo o entregarlo a otra persona, procediendo a su borrado de manera inmediata. Idiria Sociedad Limitada se reserva las acciones legales que le correspondan contra todo tercero que acceda de forma ilegítima al contenido de cualquier mensaje externo procedente del mismo. Para información y consultas visite nuestra web http://www.idiria.com Idiria Sociedad Limitada - Disclaimer This message, its content and any file attached thereto is for the intended recipient only and is confidential. If you have received this e-mail in error or had access to it, you should note that the information in it is private and any use thereof is unauthorised. In such an event please notify us by e-mail or by telephone (+ 34 690207492). Any reproduction of this e-mail by whatsoever means and any transmission or dissemination thereof to other persons is prohibited. It should be deleted immediately from your system. Idiria Sociedad Limitada reserves the right to take legal action against any persons unlawfully gaining access to the content of any external message it has emitted. For additional information, please visit our website http://www.idiria.com |
From: Ronald B. <rb...@rb...> - 2017-08-10 17:46:24
|
Right, seems the method is missing at the moment. Please open an issue.... RBRi On Thu, 10 Aug 2017 18:46:22 +0200 José Román | Idiria S.L. wrote: > >Well it seems I though it was done too soon. It fails here: > > File fileToUpload = new File("C:\firma.jpg"); > HtmlFileInput fileUploader = (HtmlFileInput) >currentPage.getFirstByXPath("//input[@type='file']"); > > fileUploader.setFiles(fileToUpload); --> This causes the exception > >GRAVE: Job run failed with unexpected RuntimeException: TypeError: Cannot >find function readAsDataURL in object [object FileReader]. ( >https://static.milanuncios.com/js/fotos/dropzone.4.2.0.min.js#1) >======= EXCEPTION START ======== >EcmaError: lineNumber=[1] column=[0] lineSource=[ function () {] >name=[TypeError] sourceName=[ >https://static.milanuncios.com/js/fotos/dropzone.4.2.0.min.js] >message=[TypeError: Cannot find function readAsDataURL in object [object >FileReader]. ( >https://static.milanuncios.com/js/fotos/dropzone.4.2.0.min.js#1)] >com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot find >function readAsDataURL in object [object FileReader]. ( >https://static.milanuncios.com/js/fotos/dropzone.4.2.0.min.js#1) >at >com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:894) >at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:637) >at >net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:518) >at >com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:823) >at >com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:795) >at >com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunction(HtmlPage.java:2504) >at >com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunction(HtmlPage.java:2497) >at >com.gargoylesoftware.htmlunit.javascript.background.JavaScriptFunctionJob.runJavaScript(JavaScriptFunctionJob.java:52) >at >com.gargoylesoftware.htmlunit.javascript.background.JavaScriptExecutionJob.run(JavaScriptExecutionJob.java:102) >at >com.gargoylesoftware.htmlunit.javascript.background.JavaScriptJobManagerImpl.runSingleJob(JavaScriptJobManagerImpl.java:424) >at >com.gargoylesoftware.htmlunit.javascript.background.DefaultJavaScriptExecutor.run(DefaultJavaScriptExecutor.java:155) >at java.lang.Thread.run(Unknown Source) >Caused by: net.sourceforge.htmlunit.corejs.javascript.EcmaError: TypeError: >Cannot find function readAsDataURL in object [object FileReader]. ( >https://static.milanuncios.com/js/fotos/dropzone.4.2.0.min.js#1) >at >net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3915) >at >net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3899) >at >net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3924) >at >net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3940) >at >net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:4007) >at >net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime.java:2402) >at >net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2384) >at >net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1348) >at >net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:800) >at >net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:105) >at >net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:416) >at >com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:322) >at >net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3264) >at >com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$4.doRun(JavaScriptEngine.java:816) >at >com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:879) >.... 11 more >Enclosed exception: >net.sourceforge.htmlunit.corejs.javascript.EcmaError: TypeError: Cannot >find function readAsDataURL in object [object FileReader]. ( >https://static.milanuncios.com/js/fotos/dropzone.4.2.0.min.js#1) >at >net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3915) >at >net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3899) >at >net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3924) >at >net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3940) >at >net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:4007) >at >net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime.java:2402) >at >net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2384) >at >net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1348) >at script(https://static.milanuncios.com/js/fotos/dropzone.4.2.0.min.js:1) >at script(https://static.milanuncios.com/js/fotos/dropzone.4.2.0.min.js:1) >at script(https://static.milanuncios.com/js/fotos/dropzone.4.2.0.min.js:1) >at >net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:800) >at >net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:105) >at >net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:416) >at >com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:322) >at >net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3264) >at >com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$4.doRun(JavaScriptEngine.java:816) >at >com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:879) >at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:637) >at >net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:518) >at >com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:823) >at >com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:795) >at >com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunction(HtmlPage.java:2504) >at >com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunction(HtmlPage.java:2497) >at >com.gargoylesoftware.htmlunit.javascript.background.JavaScriptFunctionJob.runJavaScript(JavaScriptFunctionJob.java:52) >at >com.gargoylesoftware.htmlunit.javascript.background.JavaScriptExecutionJob.run(JavaScriptExecutionJob.java:102) >at >com.gargoylesoftware.htmlunit.javascript.background.JavaScriptJobManagerImpl.runSingleJob(JavaScriptJobManagerImpl.java:424) >at >com.gargoylesoftware.htmlunit.javascript.background.DefaultJavaScriptExecutor.run(DefaultJavaScriptExecutor.java:155) >at java.lang.Thread.run(Unknown Source) >== CALLING JAVASCRIPT == > function () { > return a._processThumbnailQueue(); > } >======= EXCEPTION END ======== > > > > > > >2017-08-10 9:26 GMT+02:00 Ronald Brill <rb...@rb...>: > >> On Wed, 9 Aug 2017 18:58:31 +0200 José Román | Idiria S.L. wrote: >> > >> >1.- Open the selection dialog (or simulate it). >> >2.- Make JS process the selected files. >> > >> Without have access to the real page an answer is not that simple. >> >> >1.- Open the selection dialog (or simulate it). >> Usuall there is a input control with type 'file' somewhere on the page. >> This is more or less the only way to add files to a form to upload them. >> You have to find that control >> and use setValueAttribute with the absolute path of the file. >> >> >2.- Make JS process the selected files. >> As always there is nothing special - there is no need to deal with the js >> itselt. Simply do the same you do in the real browser e.g. click the submit >> button. HtmlUnit tries to do >> exactyl the same js processing as real browsers. >> >> >> RBRi >> -------------------------- >> WETATOR >> Smart web application testing >> http://www.wetator.org >> >> ------------------------------------------------------------ >> ------------------ >> Check out the vibrant tech community on one of the world's most >> engaging tech sites, Slashdot.org! http://sdm.link/slashdot >> _______________________________________________ >> Htmlunit-user mailing list >> Htm...@li... >> https://lists.sourceforge.net/lists/listinfo/htmlunit-user >> > > > |
From: José R. | I. S.L. <jr...@id...> - 2017-08-10 16:46:35
|
Well it seems I though it was done too soon. It fails here: File fileToUpload = new File("C:\firma.jpg"); HtmlFileInput fileUploader = (HtmlFileInput) currentPage.getFirstByXPath("//input[@type='file']"); fileUploader.setFiles(fileToUpload); --> This causes the exception GRAVE: Job run failed with unexpected RuntimeException: TypeError: Cannot find function readAsDataURL in object [object FileReader]. ( https://static.milanuncios.com/js/fotos/dropzone.4.2.0.min.js#1) ======= EXCEPTION START ======== EcmaError: lineNumber=[1] column=[0] lineSource=[ function () {] name=[TypeError] sourceName=[ https://static.milanuncios.com/js/fotos/dropzone.4.2.0.min.js] message=[TypeError: Cannot find function readAsDataURL in object [object FileReader]. ( https://static.milanuncios.com/js/fotos/dropzone.4.2.0.min.js#1)] com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot find function readAsDataURL in object [object FileReader]. ( https://static.milanuncios.com/js/fotos/dropzone.4.2.0.min.js#1) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:894) at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:637) at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:518) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:823) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:795) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunction(HtmlPage.java:2504) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunction(HtmlPage.java:2497) at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptFunctionJob.runJavaScript(JavaScriptFunctionJob.java:52) at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptExecutionJob.run(JavaScriptExecutionJob.java:102) at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptJobManagerImpl.runSingleJob(JavaScriptJobManagerImpl.java:424) at com.gargoylesoftware.htmlunit.javascript.background.DefaultJavaScriptExecutor.run(DefaultJavaScriptExecutor.java:155) at java.lang.Thread.run(Unknown Source) Caused by: net.sourceforge.htmlunit.corejs.javascript.EcmaError: TypeError: Cannot find function readAsDataURL in object [object FileReader]. ( https://static.milanuncios.com/js/fotos/dropzone.4.2.0.min.js#1) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3915) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3899) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3924) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3940) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:4007) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime.java:2402) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2384) at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1348) at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:800) at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:105) at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:416) at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:322) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3264) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$4.doRun(JavaScriptEngine.java:816) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:879) ... 11 more Enclosed exception: net.sourceforge.htmlunit.corejs.javascript.EcmaError: TypeError: Cannot find function readAsDataURL in object [object FileReader]. ( https://static.milanuncios.com/js/fotos/dropzone.4.2.0.min.js#1) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3915) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3899) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3924) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3940) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:4007) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime.java:2402) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2384) at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1348) at script(https://static.milanuncios.com/js/fotos/dropzone.4.2.0.min.js:1) at script(https://static.milanuncios.com/js/fotos/dropzone.4.2.0.min.js:1) at script(https://static.milanuncios.com/js/fotos/dropzone.4.2.0.min.js:1) at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:800) at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:105) at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:416) at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:322) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3264) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$4.doRun(JavaScriptEngine.java:816) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:879) at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:637) at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:518) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:823) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:795) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunction(HtmlPage.java:2504) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunction(HtmlPage.java:2497) at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptFunctionJob.runJavaScript(JavaScriptFunctionJob.java:52) at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptExecutionJob.run(JavaScriptExecutionJob.java:102) at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptJobManagerImpl.runSingleJob(JavaScriptJobManagerImpl.java:424) at com.gargoylesoftware.htmlunit.javascript.background.DefaultJavaScriptExecutor.run(DefaultJavaScriptExecutor.java:155) at java.lang.Thread.run(Unknown Source) == CALLING JAVASCRIPT == function () { return a._processThumbnailQueue(); } ======= EXCEPTION END ======== 2017-08-10 9:26 GMT+02:00 Ronald Brill <rb...@rb...>: > On Wed, 9 Aug 2017 18:58:31 +0200 José Román | Idiria S.L. wrote: > > > >1.- Open the selection dialog (or simulate it). > >2.- Make JS process the selected files. > > > Without have access to the real page an answer is not that simple. > > >1.- Open the selection dialog (or simulate it). > Usuall there is a input control with type 'file' somewhere on the page. > This is more or less the only way to add files to a form to upload them. > You have to find that control > and use setValueAttribute with the absolute path of the file. > > >2.- Make JS process the selected files. > As always there is nothing special - there is no need to deal with the js > itselt. Simply do the same you do in the real browser e.g. click the submit > button. HtmlUnit tries to do > exactyl the same js processing as real browsers. > > > RBRi > -------------------------- > WETATOR > Smart web application testing > http://www.wetator.org > > ------------------------------------------------------------ > ------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > -- *José Román Bilbao Castro* Ingeniero Consultor +34 901009188 *jr...@id... <jr...@id...>**http://idiria.com <http://www.idiria.com/>* <*http:// <http://%20%20/>idiria.com/ <http://idiria.com/>*> -- Idiria Sociedad Limitada - Aviso legal Este mensaje, su contenido y cualquier fichero transmitido con él está dirigido únicamente a su destinatario y es confidencial. Por ello, se informa a quien lo reciba por error ó tenga conocimiento del mismo sin ser su destinatario, que la información contenida en él es reservada y su uso no autorizado, por lo que en tal caso le rogamos nos lo comunique por la misma vía o por teléfono (+ 34 690207492), así como que se abstenga de reproducir el mensaje mediante cualquier medio o remitirlo o entregarlo a otra persona, procediendo a su borrado de manera inmediata. Idiria Sociedad Limitada se reserva las acciones legales que le correspondan contra todo tercero que acceda de forma ilegítima al contenido de cualquier mensaje externo procedente del mismo. Para información y consultas visite nuestra web http://www.idiria.com Idiria Sociedad Limitada - Disclaimer This message, its content and any file attached thereto is for the intended recipient only and is confidential. If you have received this e-mail in error or had access to it, you should note that the information in it is private and any use thereof is unauthorised. In such an event please notify us by e-mail or by telephone (+ 34 690207492). Any reproduction of this e-mail by whatsoever means and any transmission or dissemination thereof to other persons is prohibited. It should be deleted immediately from your system. Idiria Sociedad Limitada reserves the right to take legal action against any persons unlawfully gaining access to the content of any external message it has emitted. For additional information, please visit our website http://www.idiria.com |
From: José R. | I. S.L. <jr...@id...> - 2017-08-10 16:29:34
|
Found it!, thanks a lot, it was there, hidden at the end. Now, time to learn how to populate it with my files. Thanks folks! 2017-08-10 18:58 GMT+02:00 Ronald Brill <rb...@rb...>: > Looks like your page uses the dropzone.js component. > Have done some tests with the sample from page www.dropzonejs.com. > > Please open your page with an real browser and than start the developer > tools and switch to the dom exporer/inspector. If you scroll down to the > end there should be a (hidden) input field of type file. > This is not part of the page source because it will be generated at the > client side after the page was loaded. > > For HtmlUnit do this > * open the page > * wait a bit until the js is > * locate the file input and proceed as described in my last post > > > -- *José Román Bilbao Castro* Ingeniero Consultor +34 901009188 *jr...@id... <jr...@id...>**http://idiria.com <http://www.idiria.com/>* <*http:// <http://%20%20/>idiria.com/ <http://idiria.com/>*> -- Idiria Sociedad Limitada - Aviso legal Este mensaje, su contenido y cualquier fichero transmitido con él está dirigido únicamente a su destinatario y es confidencial. Por ello, se informa a quien lo reciba por error ó tenga conocimiento del mismo sin ser su destinatario, que la información contenida en él es reservada y su uso no autorizado, por lo que en tal caso le rogamos nos lo comunique por la misma vía o por teléfono (+ 34 690207492), así como que se abstenga de reproducir el mensaje mediante cualquier medio o remitirlo o entregarlo a otra persona, procediendo a su borrado de manera inmediata. Idiria Sociedad Limitada se reserva las acciones legales que le correspondan contra todo tercero que acceda de forma ilegítima al contenido de cualquier mensaje externo procedente del mismo. Para información y consultas visite nuestra web http://www.idiria.com Idiria Sociedad Limitada - Disclaimer This message, its content and any file attached thereto is for the intended recipient only and is confidential. If you have received this e-mail in error or had access to it, you should note that the information in it is private and any use thereof is unauthorised. In such an event please notify us by e-mail or by telephone (+ 34 690207492). Any reproduction of this e-mail by whatsoever means and any transmission or dissemination thereof to other persons is prohibited. It should be deleted immediately from your system. Idiria Sociedad Limitada reserves the right to take legal action against any persons unlawfully gaining access to the content of any external message it has emitted. For additional information, please visit our website http://www.idiria.com |
From: José R. | I. S.L. <jr...@id...> - 2017-08-10 16:03:00
|
Ok, I'll check it out. El 10 ago. 2017 5:58 p. m., "Ronald Brill" <rb...@rb...> escribió: > Looks like your page uses the dropzone.js component. > Have done some tests with the sample from page www.dropzonejs.com. > > Please open your page with an real browser and than start the developer > tools and switch to the dom exporer/inspector. If you scroll down to the > end there should be a (hidden) input field of type file. > This is not part of the page source because it will be generated at the > client side after the page was loaded. > > For HtmlUnit do this > * open the page > * wait a bit until the js is > * locate the file input and proceed as described in my last post > > > |
From: Ronald B. <rb...@rb...> - 2017-08-10 15:58:59
|
Looks like your page uses the dropzone.js component. Have done some tests with the sample from page www.dropzonejs.com. Please open your page with an real browser and than start the developer tools and switch to the dom exporer/inspector. If you scroll down to the end there should be a (hidden) input field of type file. This is not part of the page source because it will be generated at the client side after the page was loaded. For HtmlUnit do this * open the page * wait a bit until the js is * locate the file input and proceed as described in my last post |
From: José R. | I. S.L. <jr...@id...> - 2017-08-10 13:16:44
|
Regarding the "file" type, I could not find any. Only this: <form action="/images/upload-image-auth.php" method="post" class="dropzone dz-clickable dz-started" drop-zone="" id="photoUploader" enctype="multipart/form-data"> The multipart is the only thing related to files I can see here... 2017-08-10 9:26 GMT+02:00 Ronald Brill <rb...@rb...>: > On Wed, 9 Aug 2017 18:58:31 +0200 José Román | Idiria S.L. wrote: > > > >1.- Open the selection dialog (or simulate it). > >2.- Make JS process the selected files. > > > Without have access to the real page an answer is not that simple. > > >1.- Open the selection dialog (or simulate it). > Usuall there is a input control with type 'file' somewhere on the page. > This is more or less the only way to add files to a form to upload them. > You have to find that control > and use setValueAttribute with the absolute path of the file. > > >2.- Make JS process the selected files. > As always there is nothing special - there is no need to deal with the js > itselt. Simply do the same you do in the real browser e.g. click the submit > button. HtmlUnit tries to do > exactyl the same js processing as real browsers. > > > RBRi > -------------------------- > WETATOR > Smart web application testing > http://www.wetator.org > > ------------------------------------------------------------ > ------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > -- *José Román Bilbao Castro* Ingeniero Consultor +34 901009188 *jr...@id... <jr...@id...>**http://idiria.com <http://www.idiria.com/>* <*http:// <http://%20%20/>idiria.com/ <http://idiria.com/>*> -- Idiria Sociedad Limitada - Aviso legal Este mensaje, su contenido y cualquier fichero transmitido con él está dirigido únicamente a su destinatario y es confidencial. Por ello, se informa a quien lo reciba por error ó tenga conocimiento del mismo sin ser su destinatario, que la información contenida en él es reservada y su uso no autorizado, por lo que en tal caso le rogamos nos lo comunique por la misma vía o por teléfono (+ 34 690207492), así como que se abstenga de reproducir el mensaje mediante cualquier medio o remitirlo o entregarlo a otra persona, procediendo a su borrado de manera inmediata. Idiria Sociedad Limitada se reserva las acciones legales que le correspondan contra todo tercero que acceda de forma ilegítima al contenido de cualquier mensaje externo procedente del mismo. Para información y consultas visite nuestra web http://www.idiria.com Idiria Sociedad Limitada - Disclaimer This message, its content and any file attached thereto is for the intended recipient only and is confidential. If you have received this e-mail in error or had access to it, you should note that the information in it is private and any use thereof is unauthorised. In such an event please notify us by e-mail or by telephone (+ 34 690207492). Any reproduction of this e-mail by whatsoever means and any transmission or dissemination thereof to other persons is prohibited. It should be deleted immediately from your system. Idiria Sociedad Limitada reserves the right to take legal action against any persons unlawfully gaining access to the content of any external message it has emitted. For additional information, please visit our website http://www.idiria.com |
From: José R. | I. S.L. <jr...@id...> - 2017-08-10 13:14:19
|
But my problem is that I don't know where to start from. I can step-by-step debug my javascript code and still not able to understand how to programmatically include files. I cannot access the javascript required objects :-(. Totally lost on this last stage of the work. 2017-08-10 2:13 GMT+02:00 Guang Chao <gua...@gm...>: > > > On Thu, Aug 10, 2017 at 12:58 AM, José Román | Idiria S.L. < > jr...@id...> wrote: > >> Hi, >> >> The web page I am working with has a javascript mechanism to attach some >> files (images). The thing is that I cannot understand how to do it. There >> are to methods; a) with direct drag & drop (which I understand is not >> possible under HTMLUnit), b) through selection dialog. The thing is that I >> don't know how to: >> >> 1.- Open the selection dialog (or simulate it). >> 2.- Make JS process the selected files. >> >> The thing is that this is the first time I have to deal woth >> HTMLUnit+Javascript and I am too new to understand how to invoke things >> from Java to Javascript. >> >> It is clear the "upload-all" button does start the submission but I >> cannot see how Javascript behaves when dropping an image. If I could >> perhaps I could understand mechanics behind and imagine how to do things by >> myself... Is there a way to make a "step-by-step" debugging with this JS >> code? >> >> Here you are the code of interest for this problem: >> >> <td class="main"> >> >> <script src="https://static.milanuncios.com/js/fotos/dropzone.4.2.0. >> min.js" type="text/javascript"></script> >> <script src="https://static.milanuncios.com/js/fotos/exif.js" >> type="text/javascript"></script> >> <script src="https://static.milanuncios.com/js/fotos/dropzone-exif- >> extension.js" type="text/javascript"></script> >> <link rel="stylesheet" href="https://static.milanunci >> os.com/css/fotos/dropzone.min.css"> >> >> <script type="text/javascript"> >> function ver(id) { >> document.getElementById(id).style.position = 'absolute'; >> document.getElementById(id).style.display = 'inline'; >> document.getElementById(id).style.visibility = "visible"; >> document.getElementById(id).style.zIndex = '10000'; >> } >> >> Dropzone.options.photoUploader = { >> init: function() { >> var myDropzone = this; >> this.__photoId = 0; >> this.__uploadingPhotos = false; >> this.__isPhotoUploadDone = false; >> this.__errorMessagePrevious = ""; >> >> this.on("thumbnail", function(file){ >> ExifExtension.applyRotation(file); >> }); >> >> this.on("success", function() { >> if(this.__uploadingPhotos) >> this.processQueue(); >> }); >> >> this.options.url = function(files) { >> if (files.length !== 1) { >> alert("Error interno 5690, por favor intentalo >> más tarde"); >> return; >> } >> >> var localPhotoId = ++myDropzone.__photoId; >> >> return >> "/images/upload-image-auth.php?&idanuncio=239851259&clave= >> MldFNw%3D%3D&numfoto="+localPhotoId; >> }; >> >> this.on("processing", function() { >> ver('espera'); >> document.getElementById('upload-all').disabled = >> true; >> }); >> >> this.on("drop", function() { >> this.__errorMessagePrevious = ""; >> }); >> >> this.on("error", function(file, errorMessage) { >> console.log("error: ", errorMessage); >> if (file.status == "error") { >> if (!file.accepted) { >> this.removeFile(file); >> } else { >> errorMessage = this.options.dictResponseError >> ; >> } >> if (errorMessage != this.__errorMessagePrevious) { >> this.__errorMessagePrevious = errorMessage; >> alert(errorMessage); >> } >> } >> if(this.__uploadingPhotos) >> this.processQueue(); >> }); >> >> this.on("queuecomplete", function() { >> this.__isPhotoUploadDone = true; >> window.location = 'http://www.milanuncios.com/pu >> blicado/?idanuncio=239851259&contra=2WE7'; >> }); >> >> var submitButton = document.getElementById("upload-all"); >> submitButton.addEventListener("click", function() { >> myDropzone.__uploadingPhotos = true; >> if (myDropzone.getQueuedFiles().length == 0) { >> myDropzone.emit("queuecomplete", ""); >> } >> else { >> ver('espera'); >> myDropzone.processQueue(); >> } >> }); >> >> var dropArea = document.getElementById("dropArea"); >> dropArea.addEventListener("click", function() { >> // Clean all the previous error messages >> myDropzone.__errorMessagePrevious = ""; >> }); >> }, >> paramName: "uploadFile1", >> parallelUploads: 1, >> maxFiles: 9, >> uploadMultiple: false, >> autoProcessQueue: false, // Prevents Dropzone from uploading >> dropped files immediately >> addRemoveLinks: true, >> maxThumbnailFilesize: 5, >> maxFilesize: 5, >> thumbnailWidth: 100, >> thumbnailHeight: 100, >> imageWidth: 800, >> imageHeight: 800, >> acceptedFiles: "image/jpeg, image/gif ,image/png", >> imageQuality: 0.8, >> dictDefaultMessage: "<strong>Arrastra tus fotos aquí <br/> o >> <br/> selecciónalas de tu equipo</strong><div class=\"btnAddPhoto\">Añadir >> fotos</div>", >> dictFallbackMessage: "Tu navegador no soporta arrastrar fotos >> directamente.", >> dictFallbackText: "Utiliza el método antiguo para subir >> fotos.", >> dictFileTooBig: "La fotos es demasiado grande.", >> dictInvalidFileType: "Formato no permitido. Asegúrate que tus >> fotos son JPG, JPEG, GIF o PNG.", >> dictResponseError: "Error al subir tus fotos. Por favor, >> inténtalo de nuevo más tarde.", >> dictCancelUpload: "Cancelar", >> dictCancelUploadConfirmation: "¿Estás seguro que deseas >> cancelar la subida?", >> dictRemoveFile: "Eliminar", >> dictRemoveFileConfirmation: "¿Estás seguro que deseas >> eliminar esta foto?", >> dictMaxFilesExceeded: "No puedes subir más de 9 fotos." >> }; >> >> window.onbeforeunload = function() { >> if (Dropzone && Dropzone.instances[0] && >> !Dropzone.instances[0].__isPhotoUploadDone) { >> return "¿Realmente quieres irte sin subir tus fotos?"; >> } >> }; >> </script> >> >> <div id="dropArea"> >> <form action="/images/upload-image-auth.php" >> method="post" class="dropzone dz-clickable" drop-zone="" id="photoUploader" >> enctype="multipart/form-data"><div class="dz-default >> dz-message"><span><strong>Arrastra tus fotos aquí <br> o <br> >> selecciónalas de tu equipo</strong><div class="btnAddPhoto">Añadir >> fotos</div></span></div></form> >> </div> >> >> <div class="uploadBtnBox"> >> <button id="upload-all" class="uploadBtn">Finalizar >> publicación</button> >> </div> >> </div> >> </div> >> >> >> > Working with JavaScript is case to case basis to make it work. When I > work with Selenium before, I need to change to different drivers on which > one will work for a specific site. Its really tricky. > > >> >> -- >> >> >> *José Román Bilbao Castro* >> >> Ingeniero Consultor >> +34 901009188 >> >> *jr...@id... <jr...@id...>**http://idiria.com >> <http://www.idiria.com/>* <*http:// <http://%20%20/>idiria.com/ >> <http://idiria.com/>*> >> >> -- >> Idiria Sociedad Limitada - Aviso legal >> >> Este mensaje, su contenido y cualquier fichero transmitido con él está >> dirigido únicamente a su destinatario y es confidencial. Por ello, se >> informa a quien lo reciba por error ó tenga conocimiento del mismo sin ser >> su destinatario, que la información contenida en él es reservada y su uso >> no autorizado, por lo que en tal caso le rogamos nos lo comunique por la >> misma vía o por teléfono (+ 34 690207492), así como que se abstenga de >> reproducir el mensaje mediante cualquier medio o remitirlo o entregarlo a >> otra persona, procediendo a su borrado de manera inmediata. >> >> Idiria Sociedad Limitada se reserva las acciones legales que le >> correspondan contra todo tercero que acceda de forma ilegítima al >> contenido de cualquier mensaje externo procedente del mismo. >> >> Para información y consultas visite nuestra web http://www.idiria.com >> >> >> >> Idiria Sociedad Limitada - Disclaimer >> This message, its content and any file attached thereto is for the >> intended recipient only and is confidential. If you have received this >> e-mail in error or had access to it, you should note that the information >> in it is private and any use thereof is unauthorised. In such an event >> please notify us by e-mail or by telephone (+ 34 690207492). Any >> reproduction of this e-mail by whatsoever means and any transmission or >> dissemination thereof to other persons is prohibited. It should be deleted >> immediately from your system. >> >> Idiria Sociedad Limitada reserves the right to take legal action against >> any persons unlawfully gaining access to the content of any external >> message it has emitted. >> >> For additional information, please visit our website >> http://www.idiria.com >> >> >> >> ------------------------------------------------------------ >> ------------------ >> Check out the vibrant tech community on one of the world's most >> engaging tech sites, Slashdot.org! http://sdm.link/slashdot >> _______________________________________________ >> Htmlunit-user mailing list >> Htm...@li... >> https://lists.sourceforge.net/lists/listinfo/htmlunit-user >> >> > > > -- > Guang > <http://javadevnotes.com/java-string-split-space-or-whitespace-examples> > > ------------------------------------------------------------ > ------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > > -- *José Román Bilbao Castro* Ingeniero Consultor +34 901009188 *jr...@id... <jr...@id...>**http://idiria.com <http://www.idiria.com/>* <*http:// <http://%20%20/>idiria.com/ <http://idiria.com/>*> -- Idiria Sociedad Limitada - Aviso legal Este mensaje, su contenido y cualquier fichero transmitido con él está dirigido únicamente a su destinatario y es confidencial. Por ello, se informa a quien lo reciba por error ó tenga conocimiento del mismo sin ser su destinatario, que la información contenida en él es reservada y su uso no autorizado, por lo que en tal caso le rogamos nos lo comunique por la misma vía o por teléfono (+ 34 690207492), así como que se abstenga de reproducir el mensaje mediante cualquier medio o remitirlo o entregarlo a otra persona, procediendo a su borrado de manera inmediata. Idiria Sociedad Limitada se reserva las acciones legales que le correspondan contra todo tercero que acceda de forma ilegítima al contenido de cualquier mensaje externo procedente del mismo. Para información y consultas visite nuestra web http://www.idiria.com Idiria Sociedad Limitada - Disclaimer This message, its content and any file attached thereto is for the intended recipient only and is confidential. If you have received this e-mail in error or had access to it, you should note that the information in it is private and any use thereof is unauthorised. In such an event please notify us by e-mail or by telephone (+ 34 690207492). Any reproduction of this e-mail by whatsoever means and any transmission or dissemination thereof to other persons is prohibited. It should be deleted immediately from your system. Idiria Sociedad Limitada reserves the right to take legal action against any persons unlawfully gaining access to the content of any external message it has emitted. For additional information, please visit our website http://www.idiria.com |
From: Albu G. <alb...@gm...> - 2017-08-10 10:27:54
|
Not a specific answer to your question but generally it's a good idea to use htmlunitscripter Firefox extension to have a first idea of what sort of code to write for a specific action. With it you can record your action and retrieve a code sequence by using htmlunit. I used it very often and it saved me a lot of time. Le 10/08/2017 à 02:13, Guang Chao a écrit : > > > On Thu, Aug 10, 2017 at 12:58 AM, José Román | Idiria S.L. > <jr...@id... <mailto:jr...@id...>> wrote: > > Hi, > > The web page I am working with has a javascript mechanism to > attach some files (images). The thing is that I cannot understand > how to do it. There are to methods; a) with direct drag & drop > (which I understand is not possible under HTMLUnit), b) through > selection dialog. The thing is that I don't know how to: > > 1.- Open the selection dialog (or simulate it). > 2.- Make JS process the selected files. > > The thing is that this is the first time I have to deal woth > HTMLUnit+Javascript and I am too new to understand how to invoke > things from Java to Javascript. > > It is clear the "upload-all" button does start the submission but > I cannot see how Javascript behaves when dropping an image. If I > could perhaps I could understand mechanics behind and imagine how > to do things by myself... Is there a way to make a "step-by-step" > debugging with this JS code? > > Here you are the code of interest for this problem: > > <td class="main"> > > <script > src="https://static.milanuncios.com/js/fotos/dropzone.4.2.0.min.js > <https://static.milanuncios.com/js/fotos/dropzone.4.2.0.min.js>" > type="text/javascript"></script> > <script src="https://static.milanuncios.com/js/fotos/exif.js > <https://static.milanuncios.com/js/fotos/exif.js>" > type="text/javascript"></script> > <script > src="https://static.milanuncios.com/js/fotos/dropzone-exif-extension.js > <https://static.milanuncios.com/js/fotos/dropzone-exif-extension.js>" > type="text/javascript"></script> > <link rel="stylesheet" > href="https://static.milanuncios.com/css/fotos/dropzone.min.css > <https://static.milanuncios.com/css/fotos/dropzone.min.css>"> > > <script type="text/javascript"> > function ver(id) { > document.getElementById(id).style.position = 'absolute'; > document.getElementById(id).style.display = 'inline'; > document.getElementById(id).style.visibility = "visible"; > document.getElementById(id).style.zIndex = '10000'; > } > > Dropzone.options.photoUploader = { > init: function() { > var myDropzone = this; > this.__photoId = 0; > this.__uploadingPhotos = false; > this.__isPhotoUploadDone = false; > this.__errorMessagePrevious = ""; > > this.on("thumbnail", function(file){ > ExifExtension.applyRotation(file); > }); > > this.on("success", function() { > if(this.__uploadingPhotos) > this.processQueue(); > }); > > this.options.url = function(files) { > if (files.length !== 1) { > alert("Error interno 5690, por favor > intentalo más tarde"); > return; > } > > var localPhotoId = ++myDropzone.__photoId; > > return > "/images/upload-image-auth.php?&idanuncio=239851259&clave=MldFNw%3D%3D&numfoto="+localPhotoId; > }; > > this.on("processing", function() { > ver('espera'); > document.getElementById('upload-all').disabled > = true; > }); > > this.on("drop", function() { > this.__errorMessagePrevious = ""; > }); > > this.on("error", function(file, errorMessage) { > console.log("error: ", errorMessage); > if (file.status == "error") { > if (!file.accepted) { > this.removeFile(file); > } else { > errorMessage = > this.options.dictResponseError; > } > if (errorMessage != > this.__errorMessagePrevious) { > this.__errorMessagePrevious = errorMessage; > alert(errorMessage); > } > } > if(this.__uploadingPhotos) > this.processQueue(); > }); > > this.on("queuecomplete", function() { > this.__isPhotoUploadDone = true; > window.location = > 'http://www.milanuncios.com/publicado/?idanuncio=239851259&contra=2WE7 > <http://www.milanuncios.com/publicado/?idanuncio=239851259&contra=2WE7>'; > }); > > var submitButton = > document.getElementById("upload-all"); > submitButton.addEventListener("click", function() { > myDropzone.__uploadingPhotos = true; > if (myDropzone.getQueuedFiles().length == 0) { > myDropzone.emit("queuecomplete", ""); > } > else { > ver('espera'); > myDropzone.processQueue(); > } > }); > > var dropArea = document.getElementById("dropArea"); > dropArea.addEventListener("click", function() { > // Clean all the previous error messages > myDropzone.__errorMessagePrevious = ""; > }); > }, > paramName: "uploadFile1", > parallelUploads: 1, > maxFiles: 9, > uploadMultiple: false, > autoProcessQueue: false, // Prevents Dropzone from > uploading dropped files immediately > addRemoveLinks: true, > maxThumbnailFilesize: 5, > maxFilesize: 5, > thumbnailWidth: 100, > thumbnailHeight: 100, > imageWidth: 800, > imageHeight: 800, > acceptedFiles: "image/jpeg, image/gif ,image/png", > imageQuality: 0.8, > dictDefaultMessage: "<strong>Arrastra tus fotos aquí > <br/> o <br/> selecciónalas de tu equipo</strong><div > class=\"btnAddPhoto\">Añadir fotos</div>", > dictFallbackMessage: "Tu navegador no soporta > arrastrar fotos directamente.", > dictFallbackText: "Utiliza el método antiguo para > subir fotos.", > dictFileTooBig: "La fotos es demasiado grande.", > dictInvalidFileType: "Formato no permitido. Asegúrate > que tus fotos son JPG, JPEG, GIF o PNG.", > dictResponseError: "Error al subir tus fotos. Por > favor, inténtalo de nuevo más tarde.", > dictCancelUpload: "Cancelar", > dictCancelUploadConfirmation: "¿Estás seguro que > deseas cancelar la subida?", > dictRemoveFile: "Eliminar", > dictRemoveFileConfirmation: "¿Estás seguro que deseas > eliminar esta foto?", > dictMaxFilesExceeded: "No puedes subir más de 9 fotos." > }; > > window.onbeforeunload = function() { > if (Dropzone && Dropzone.instances[0] && > !Dropzone.instances[0].__isPhotoUploadDone) { > return "¿Realmente quieres irte sin subir tus fotos?"; > } > }; > </script> > > <div id="dropArea"> > <form action="/images/upload-image-auth.php" > method="post" class="dropzone dz-clickable" drop-zone="" > id="photoUploader" enctype="multipart/form-data"><div > class="dz-default dz-message"><span><strong>Arrastra tus fotos > aquí <br> o <br> selecciónalas de tu equipo</strong><div > class="btnAddPhoto">Añadir fotos</div></span></div></form> > </div> > > <div class="uploadBtnBox"> > <button id="upload-all" > class="uploadBtn">Finalizar publicación</button> > </div> > </div> > </div> > > > > Working with JavaScript is case to case basis to make it work. When I > work with Selenium before, I need to change to different drivers on > which one will work for a specific site. Its really tricky. > > > -- > > * > José Román Bilbao Castro* > > Ingeniero Consultor > +34 901009188 > _jr...@id... <mailto:jr...@id...> > __http://idiria.com <http://www.idiria.com/>_ <_http:// > <http://%20%20/>idiria.com/ <http://idiria.com/>_> > > -- > Idiria Sociedad Limitada - Aviso legal > > Este mensaje, su contenido y cualquier fichero transmitido con él > está dirigido únicamente a su destinatario y es confidencial. Por > ello, se informa a quien lo reciba por error ó tenga conocimiento > del mismo sin ser su destinatario, que la información contenida en > él es reservada y su uso no autorizado, por lo que en tal caso le > rogamos nos lo comunique por la misma vía o por teléfono (+ 34 > 690207492), así como que se abstenga de reproducir el mensaje > mediante cualquier medio o remitirlo o entregarlo a otra persona, > procediendo a su borrado de manera inmediata. > > Idiria Sociedad Limitada se reserva las acciones legales que le > correspondan contra todo tercero que acceda de forma ilegítima al > contenido de cualquier mensaje externo procedente del mismo. > > Para información y consultas visite nuestra web > http://www.idiria.com <http://www.idiria.com/> > > > > Idiria Sociedad Limitada - Disclaimer > This message, its content and any file attached thereto is for the > intended recipient only and is confidential. If you have received > this e-mail in error or had access to it, you should note that the > information in it is private and any use thereof is unauthorised. > In such an event please notify us by e-mail or by telephone (+ 34 > 690207492). Any reproduction of this e-mail by whatsoever means > and any transmission or dissemination thereof to other persons is > prohibited. It should be deleted immediately from your system. > > Idiria Sociedad Limitada reserves the right to take legal action > against any persons unlawfully gaining access to the content of > any external message it has emitted. > > For additional information, please visit our website > http://www.idiria.com <http://www.idiria.com/> > > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > <mailto:Htm...@li...> > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > <https://lists.sourceforge.net/lists/listinfo/htmlunit-user> > > > > > -- > Guang > <http://javadevnotes.com/java-string-split-space-or-whitespace-examples> > > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > > > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user |
From: Ronald B. <rb...@rb...> - 2017-08-10 06:27:05
|
On Wed, 9 Aug 2017 18:58:31 +0200 José Román | Idiria S.L. wrote: > >1.- Open the selection dialog (or simulate it). >2.- Make JS process the selected files. > Without have access to the real page an answer is not that simple. >1.- Open the selection dialog (or simulate it). Usuall there is a input control with type 'file' somewhere on the page. This is more or less the only way to add files to a form to upload them. You have to find that control and use setValueAttribute with the absolute path of the file. >2.- Make JS process the selected files. As always there is nothing special - there is no need to deal with the js itselt. Simply do the same you do in the real browser e.g. click the submit button. HtmlUnit tries to do exactyl the same js processing as real browsers. RBRi -------------------------- WETATOR Smart web application testing http://www.wetator.org |
From: Guang C. <gua...@gm...> - 2017-08-10 00:13:55
|
On Thu, Aug 10, 2017 at 12:58 AM, José Román | Idiria S.L. < jr...@id...> wrote: > Hi, > > The web page I am working with has a javascript mechanism to attach some > files (images). The thing is that I cannot understand how to do it. There > are to methods; a) with direct drag & drop (which I understand is not > possible under HTMLUnit), b) through selection dialog. The thing is that I > don't know how to: > > 1.- Open the selection dialog (or simulate it). > 2.- Make JS process the selected files. > > The thing is that this is the first time I have to deal woth > HTMLUnit+Javascript and I am too new to understand how to invoke things > from Java to Javascript. > > It is clear the "upload-all" button does start the submission but I cannot > see how Javascript behaves when dropping an image. If I could perhaps I > could understand mechanics behind and imagine how to do things by myself... > Is there a way to make a "step-by-step" debugging with this JS code? > > Here you are the code of interest for this problem: > > <td class="main"> > > <script src="https://static.milanuncios.com/js/fotos/ > dropzone.4.2.0.min.js" type="text/javascript"></script> > <script src="https://static.milanuncios.com/js/fotos/exif.js" > type="text/javascript"></script> > <script src="https://static.milanuncios.com/js/fotos/ > dropzone-exif-extension.js" type="text/javascript"></script> > <link rel="stylesheet" href="https://static.milanuncios.com/css/fotos/ > dropzone.min.css"> > > <script type="text/javascript"> > function ver(id) { > document.getElementById(id).style.position = 'absolute'; > document.getElementById(id).style.display = 'inline'; > document.getElementById(id).style.visibility = "visible"; > document.getElementById(id).style.zIndex = '10000'; > } > > Dropzone.options.photoUploader = { > init: function() { > var myDropzone = this; > this.__photoId = 0; > this.__uploadingPhotos = false; > this.__isPhotoUploadDone = false; > this.__errorMessagePrevious = ""; > > this.on("thumbnail", function(file){ > ExifExtension.applyRotation(file); > }); > > this.on("success", function() { > if(this.__uploadingPhotos) > this.processQueue(); > }); > > this.options.url = function(files) { > if (files.length !== 1) { > alert("Error interno 5690, por favor intentalo más > tarde"); > return; > } > > var localPhotoId = ++myDropzone.__photoId; > > return "/images/upload-image-auth. > php?&idanuncio=239851259&clave=MldFNw%3D%3D&numfoto="+localPhotoId; > }; > > this.on("processing", function() { > ver('espera'); > document.getElementById('upload-all').disabled = true; > }); > > this.on("drop", function() { > this.__errorMessagePrevious = ""; > }); > > this.on("error", function(file, errorMessage) { > console.log("error: ", errorMessage); > if (file.status == "error") { > if (!file.accepted) { > this.removeFile(file); > } else { > errorMessage = this.options.dictResponseError; > } > if (errorMessage != this.__errorMessagePrevious) { > this.__errorMessagePrevious = errorMessage; > alert(errorMessage); > } > } > if(this.__uploadingPhotos) > this.processQueue(); > }); > > this.on("queuecomplete", function() { > this.__isPhotoUploadDone = true; > window.location = 'http://www.milanuncios.com/ > publicado/?idanuncio=239851259&contra=2WE7'; > }); > > var submitButton = document.getElementById("upload-all"); > submitButton.addEventListener("click", function() { > myDropzone.__uploadingPhotos = true; > if (myDropzone.getQueuedFiles().length == 0) { > myDropzone.emit("queuecomplete", ""); > } > else { > ver('espera'); > myDropzone.processQueue(); > } > }); > > var dropArea = document.getElementById("dropArea"); > dropArea.addEventListener("click", function() { > // Clean all the previous error messages > myDropzone.__errorMessagePrevious = ""; > }); > }, > paramName: "uploadFile1", > parallelUploads: 1, > maxFiles: 9, > uploadMultiple: false, > autoProcessQueue: false, // Prevents Dropzone from uploading > dropped files immediately > addRemoveLinks: true, > maxThumbnailFilesize: 5, > maxFilesize: 5, > thumbnailWidth: 100, > thumbnailHeight: 100, > imageWidth: 800, > imageHeight: 800, > acceptedFiles: "image/jpeg, image/gif ,image/png", > imageQuality: 0.8, > dictDefaultMessage: "<strong>Arrastra tus fotos aquí <br/> o > <br/> selecciónalas de tu equipo</strong><div class=\"btnAddPhoto\">Añadir > fotos</div>", > dictFallbackMessage: "Tu navegador no soporta arrastrar fotos > directamente.", > dictFallbackText: "Utiliza el método antiguo para subir > fotos.", > dictFileTooBig: "La fotos es demasiado grande.", > dictInvalidFileType: "Formato no permitido. Asegúrate que tus > fotos son JPG, JPEG, GIF o PNG.", > dictResponseError: "Error al subir tus fotos. Por favor, > inténtalo de nuevo más tarde.", > dictCancelUpload: "Cancelar", > dictCancelUploadConfirmation: "¿Estás seguro que deseas > cancelar la subida?", > dictRemoveFile: "Eliminar", > dictRemoveFileConfirmation: "¿Estás seguro que deseas eliminar > esta foto?", > dictMaxFilesExceeded: "No puedes subir más de 9 fotos." > }; > > window.onbeforeunload = function() { > if (Dropzone && Dropzone.instances[0] && > !Dropzone.instances[0].__isPhotoUploadDone) { > return "¿Realmente quieres irte sin subir tus fotos?"; > } > }; > </script> > > <div id="dropArea"> > <form action="/images/upload-image-auth.php" > method="post" class="dropzone dz-clickable" drop-zone="" id="photoUploader" > enctype="multipart/form-data"><div class="dz-default > dz-message"><span><strong>Arrastra tus fotos aquí <br> o <br> > selecciónalas de tu equipo</strong><div class="btnAddPhoto">Añadir > fotos</div></span></div></form> > </div> > > <div class="uploadBtnBox"> > <button id="upload-all" class="uploadBtn">Finalizar > publicación</button> > </div> > </div> > </div> > > > Working with JavaScript is case to case basis to make it work. When I work with Selenium before, I need to change to different drivers on which one will work for a specific site. Its really tricky. > > -- > > > *José Román Bilbao Castro* > > Ingeniero Consultor > +34 901009188 > > *jr...@id... <jr...@id...>**http://idiria.com > <http://www.idiria.com/>* <*http:// <http://%20%20/>idiria.com/ > <http://idiria.com/>*> > > -- > Idiria Sociedad Limitada - Aviso legal > > Este mensaje, su contenido y cualquier fichero transmitido con él está > dirigido únicamente a su destinatario y es confidencial. Por ello, se > informa a quien lo reciba por error ó tenga conocimiento del mismo sin ser > su destinatario, que la información contenida en él es reservada y su uso > no autorizado, por lo que en tal caso le rogamos nos lo comunique por la > misma vía o por teléfono (+ 34 690207492), así como que se abstenga de > reproducir el mensaje mediante cualquier medio o remitirlo o entregarlo a > otra persona, procediendo a su borrado de manera inmediata. > > Idiria Sociedad Limitada se reserva las acciones legales que le > correspondan contra todo tercero que acceda de forma ilegítima al > contenido de cualquier mensaje externo procedente del mismo. > > Para información y consultas visite nuestra web http://www.idiria.com > > > > Idiria Sociedad Limitada - Disclaimer > This message, its content and any file attached thereto is for the > intended recipient only and is confidential. If you have received this > e-mail in error or had access to it, you should note that the information > in it is private and any use thereof is unauthorised. In such an event > please notify us by e-mail or by telephone (+ 34 690207492). Any > reproduction of this e-mail by whatsoever means and any transmission or > dissemination thereof to other persons is prohibited. It should be deleted > immediately from your system. > > Idiria Sociedad Limitada reserves the right to take legal action against > any persons unlawfully gaining access to the content of any external > message it has emitted. > > For additional information, please visit our website http://www.idiria.com > > > > > ------------------------------------------------------------ > ------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > > -- Guang <http://javadevnotes.com/java-string-split-space-or-whitespace-examples> |
From: José R. | I. S.L. <jr...@id...> - 2017-08-09 16:58:40
|
Hi, The web page I am working with has a javascript mechanism to attach some files (images). The thing is that I cannot understand how to do it. There are to methods; a) with direct drag & drop (which I understand is not possible under HTMLUnit), b) through selection dialog. The thing is that I don't know how to: 1.- Open the selection dialog (or simulate it). 2.- Make JS process the selected files. The thing is that this is the first time I have to deal woth HTMLUnit+Javascript and I am too new to understand how to invoke things from Java to Javascript. It is clear the "upload-all" button does start the submission but I cannot see how Javascript behaves when dropping an image. If I could perhaps I could understand mechanics behind and imagine how to do things by myself... Is there a way to make a "step-by-step" debugging with this JS code? Here you are the code of interest for this problem: <td class="main"> <script src=" https://static.milanuncios.com/js/fotos/dropzone.4.2.0.min.js" type="text/javascript"></script> <script src="https://static.milanuncios.com/js/fotos/exif.js" type="text/javascript"></script> <script src=" https://static.milanuncios.com/js/fotos/dropzone-exif-extension.js" type="text/javascript"></script> <link rel="stylesheet" href=" https://static.milanuncios.com/css/fotos/dropzone.min.css"> <script type="text/javascript"> function ver(id) { document.getElementById(id).style.position = 'absolute'; document.getElementById(id).style.display = 'inline'; document.getElementById(id).style.visibility = "visible"; document.getElementById(id).style.zIndex = '10000'; } Dropzone.options.photoUploader = { init: function() { var myDropzone = this; this.__photoId = 0; this.__uploadingPhotos = false; this.__isPhotoUploadDone = false; this.__errorMessagePrevious = ""; this.on("thumbnail", function(file){ ExifExtension.applyRotation(file); }); this.on("success", function() { if(this.__uploadingPhotos) this.processQueue(); }); this.options.url = function(files) { if (files.length !== 1) { alert("Error interno 5690, por favor intentalo más tarde"); return; } var localPhotoId = ++myDropzone.__photoId; return "/images/upload-image-auth.php?&idanuncio=239851259&clave=MldFNw%3D%3D&numfoto="+localPhotoId; }; this.on("processing", function() { ver('espera'); document.getElementById('upload-all').disabled = true; }); this.on("drop", function() { this.__errorMessagePrevious = ""; }); this.on("error", function(file, errorMessage) { console.log("error: ", errorMessage); if (file.status == "error") { if (!file.accepted) { this.removeFile(file); } else { errorMessage = this.options.dictResponseError; } if (errorMessage != this.__errorMessagePrevious) { this.__errorMessagePrevious = errorMessage; alert(errorMessage); } } if(this.__uploadingPhotos) this.processQueue(); }); this.on("queuecomplete", function() { this.__isPhotoUploadDone = true; window.location = ' http://www.milanuncios.com/publicado/?idanuncio=239851259&contra=2WE7'; }); var submitButton = document.getElementById("upload-all"); submitButton.addEventListener("click", function() { myDropzone.__uploadingPhotos = true; if (myDropzone.getQueuedFiles().length == 0) { myDropzone.emit("queuecomplete", ""); } else { ver('espera'); myDropzone.processQueue(); } }); var dropArea = document.getElementById("dropArea"); dropArea.addEventListener("click", function() { // Clean all the previous error messages myDropzone.__errorMessagePrevious = ""; }); }, paramName: "uploadFile1", parallelUploads: 1, maxFiles: 9, uploadMultiple: false, autoProcessQueue: false, // Prevents Dropzone from uploading dropped files immediately addRemoveLinks: true, maxThumbnailFilesize: 5, maxFilesize: 5, thumbnailWidth: 100, thumbnailHeight: 100, imageWidth: 800, imageHeight: 800, acceptedFiles: "image/jpeg, image/gif ,image/png", imageQuality: 0.8, dictDefaultMessage: "<strong>Arrastra tus fotos aquí <br/> o <br/> selecciónalas de tu equipo</strong><div class=\"btnAddPhoto\">Añadir fotos</div>", dictFallbackMessage: "Tu navegador no soporta arrastrar fotos directamente.", dictFallbackText: "Utiliza el método antiguo para subir fotos.", dictFileTooBig: "La fotos es demasiado grande.", dictInvalidFileType: "Formato no permitido. Asegúrate que tus fotos son JPG, JPEG, GIF o PNG.", dictResponseError: "Error al subir tus fotos. Por favor, inténtalo de nuevo más tarde.", dictCancelUpload: "Cancelar", dictCancelUploadConfirmation: "¿Estás seguro que deseas cancelar la subida?", dictRemoveFile: "Eliminar", dictRemoveFileConfirmation: "¿Estás seguro que deseas eliminar esta foto?", dictMaxFilesExceeded: "No puedes subir más de 9 fotos." }; window.onbeforeunload = function() { if (Dropzone && Dropzone.instances[0] && !Dropzone.instances[0].__isPhotoUploadDone) { return "¿Realmente quieres irte sin subir tus fotos?"; } }; </script> <div id="dropArea"> <form action="/images/upload-image-auth.php" method="post" class="dropzone dz-clickable" drop-zone="" id="photoUploader" enctype="multipart/form-data"><div class="dz-default dz-message"><span><strong>Arrastra tus fotos aquí <br> o <br> selecciónalas de tu equipo</strong><div class="btnAddPhoto">Añadir fotos</div></span></div></form> </div> <div class="uploadBtnBox"> <button id="upload-all" class="uploadBtn">Finalizar publicación</button> </div> </div> </div> -- *José Román Bilbao Castro* Ingeniero Consultor +34 901009188 *jr...@id... <jr...@id...>**http://idiria.com <http://www.idiria.com/>* <*http:// <http://%20%20/>idiria.com/ <http://idiria.com/>*> -- Idiria Sociedad Limitada - Aviso legal Este mensaje, su contenido y cualquier fichero transmitido con él está dirigido únicamente a su destinatario y es confidencial. Por ello, se informa a quien lo reciba por error ó tenga conocimiento del mismo sin ser su destinatario, que la información contenida en él es reservada y su uso no autorizado, por lo que en tal caso le rogamos nos lo comunique por la misma vía o por teléfono (+ 34 690207492), así como que se abstenga de reproducir el mensaje mediante cualquier medio o remitirlo o entregarlo a otra persona, procediendo a su borrado de manera inmediata. Idiria Sociedad Limitada se reserva las acciones legales que le correspondan contra todo tercero que acceda de forma ilegítima al contenido de cualquier mensaje externo procedente del mismo. Para información y consultas visite nuestra web http://www.idiria.com Idiria Sociedad Limitada - Disclaimer This message, its content and any file attached thereto is for the intended recipient only and is confidential. If you have received this e-mail in error or had access to it, you should note that the information in it is private and any use thereof is unauthorised. In such an event please notify us by e-mail or by telephone (+ 34 690207492). Any reproduction of this e-mail by whatsoever means and any transmission or dissemination thereof to other persons is prohibited. It should be deleted immediately from your system. Idiria Sociedad Limitada reserves the right to take legal action against any persons unlawfully gaining access to the content of any external message it has emitted. For additional information, please visit our website http://www.idiria.com |
From: jp l. <jp....@gm...> - 2017-08-03 20:12:35
|
yeah, It's very useful, I am building some automated testing for some platform made in PHP + JS ... Running Junits with HtmlUnit in Jenkins, so far so good. Anyway JS it is painful to test. On Thu, Aug 3, 2017 at 10:00 PM, Ronald Brill <rb...@rb...> wrote: > You are welcome. Hope you find HtmlUnit useful. > > RBRi > > On Thu, 3 Aug 2017 21:05:07 +0200 jp list wrote: >> >>Hi Ronald >> >>thank you very much for your email. It was very very useful. >> >>I was blind thinking was a popup. >> >>thank you again ! >> >>On Thu, Aug 3, 2017 at 8:53 AM, Ronald Brill <rb...@rb...> wrote: >>> Hi jp list ;-) >>> >>> because your code is not complete and there is at least no url i can test with i have to > guess a bit and i like to add some hints >>> >>> At first - the setup of your web client >>> Even if stackoverflow today has solutions of everything it is not always a good idea to > copy that stuff without knowing what the implications of that code. >>> The idea of the default setup of the webclient is to configure the client as close as > possible to your real browser (because HtmlUnit is designed for application testing there is > one >>> exception of this rule regarding js error handling). >>> So please start without setting any option and change only the required options on > demand >>> >>>> webClient.getOptions().setThrowExceptionOnScriptError(false); >>> This is the one exception of the general rule. But it is a good idea to do this only if you > are facing js exceptions. >>> Keep also in mind that if a js exception is thrown the js execution is stopped. If you got a > js execption, compare with real browsers. If this exception is not thrown in real >>> browsers, this might suppress some js code be required to open the popup or send the > data >>> >>>> webClient.getOptions().setJavaScriptEnabled(true); >>> This is already the default. >>> >>>> webClient.waitForBackgroundJavaScript(30000); >>> As i mentioned many times on stackoverflow this is NOT an option, doing this at this > place is nonsens. >>> >>>> webClient.getOptions().setActiveXNative(true); >>>> webClient.getOptions().setAppletEnabled(true); >>> Do you really need ActivX support (you are using the default browser ChromeSimulation > at the moment)? >>> Do you really need Applet support? >>> >>>> webClient.getOptions().setCssEnabled(true); >>> This is already the default. >>> >>>> webClient.getOptions().setUseInsecureSSL(true); >>> This makes sense if you like to address application with invalid certificates. >>> >>> >>> Ok, so far for the setup >>> >>>><div class="bootbox modal fade in" tabindex="-1" role="dialog" >>>>aria-hidden="false" style="display: block; padding-right: 15px;"> >>>> <div class="modal-backdrop fade in" sHi there. >>> >>> Next point is your idea of an popup. You have to understand the way browsers are > working. Today browsers are usually using tabs when a new 'window' gets opend. This >>> might be the result of anchor click with a target. Another option is the use of the > javascript open funtions. >>> But most of the modern applications / frameworks are not doing this. They are doing > some 'fake' windowing by placing some gray rectangle on top of your page and than >>> placing some window look alike html stuff on top of this. Your code sample looks like > this solution (usually there is a lot of js/css magic behind to make this happen). >>> >>> So forget/remove the window listener stuff from your code. >>> The dialog is part of your current page. >>> >>> In general your code should work like that >>> * navigate to the start page >>> * locate the element that opens the dialog >>> * click the element to open the dialog >>> * optional: wait a bit to finish the magic > (webClient.waitForBackgroundJavaScript(1000);) >>> * locate the dialog button you like to click from the current page (looks like there is no id > - you have to use XPath or iterate over all buttons on the page and select the right one >>> by checking for e.g. the css class and/or other attributes >>> * click the button >>> * optional: wait a bit to finish the magic > (webClient.waitForBackgroundJavaScript(1000);) >>> >>>> webClient.getOptions().setThrowExceptionOnScriptError(false); >>> Keep also in mind that if a js exception is thrown the js execution is stopped. If you got a > js execption, compare with real browsers. If this exception is not thrown in real >>> browsers, this might suppress some js code be required to open the popup or send the > data. If you have this kind of problems please open an issue. >>> >>> And as always use the latest SNAPSHOT build. >>> >>> Hope that helps, if not feel free to provide more details >>> >>> RBRi >> > |
From: Ronald B. <rb...@rb...> - 2017-08-03 20:00:55
|
You are welcome. Hope you find HtmlUnit useful. RBRi On Thu, 3 Aug 2017 21:05:07 +0200 jp list wrote: > >Hi Ronald > >thank you very much for your email. It was very very useful. > >I was blind thinking was a popup. > >thank you again ! > >On Thu, Aug 3, 2017 at 8:53 AM, Ronald Brill <rb...@rb...> wrote: >> Hi jp list ;-) >> >> because your code is not complete and there is at least no url i can test with i have to guess a bit and i like to add some hints >> >> At first - the setup of your web client >> Even if stackoverflow today has solutions of everything it is not always a good idea to copy that stuff without knowing what the implications of that code. >> The idea of the default setup of the webclient is to configure the client as close as possible to your real browser (because HtmlUnit is designed for application testing there is one >> exception of this rule regarding js error handling). >> So please start without setting any option and change only the required options on demand >> >>> webClient.getOptions().setThrowExceptionOnScriptError(false); >> This is the one exception of the general rule. But it is a good idea to do this only if you are facing js exceptions. >> Keep also in mind that if a js exception is thrown the js execution is stopped. If you got a js execption, compare with real browsers. If this exception is not thrown in real >> browsers, this might suppress some js code be required to open the popup or send the data >> >>> webClient.getOptions().setJavaScriptEnabled(true); >> This is already the default. >> >>> webClient.waitForBackgroundJavaScript(30000); >> As i mentioned many times on stackoverflow this is NOT an option, doing this at this place is nonsens. >> >>> webClient.getOptions().setActiveXNative(true); >>> webClient.getOptions().setAppletEnabled(true); >> Do you really need ActivX support (you are using the default browser ChromeSimulation at the moment)? >> Do you really need Applet support? >> >>> webClient.getOptions().setCssEnabled(true); >> This is already the default. >> >>> webClient.getOptions().setUseInsecureSSL(true); >> This makes sense if you like to address application with invalid certificates. >> >> >> Ok, so far for the setup >> >>><div class="bootbox modal fade in" tabindex="-1" role="dialog" >>>aria-hidden="false" style="display: block; padding-right: 15px;"> >>> <div class="modal-backdrop fade in" sHi there. >> >> Next point is your idea of an popup. You have to understand the way browsers are working. Today browsers are usually using tabs when a new 'window' gets opend. This >> might be the result of anchor click with a target. Another option is the use of the javascript open funtions. >> But most of the modern applications / frameworks are not doing this. They are doing some 'fake' windowing by placing some gray rectangle on top of your page and than >> placing some window look alike html stuff on top of this. Your code sample looks like this solution (usually there is a lot of js/css magic behind to make this happen). >> >> So forget/remove the window listener stuff from your code. >> The dialog is part of your current page. >> >> In general your code should work like that >> * navigate to the start page >> * locate the element that opens the dialog >> * click the element to open the dialog >> * optional: wait a bit to finish the magic (webClient.waitForBackgroundJavaScript(1000);) >> * locate the dialog button you like to click from the current page (looks like there is no id - you have to use XPath or iterate over all buttons on the page and select the right one >> by checking for e.g. the css class and/or other attributes >> * click the button >> * optional: wait a bit to finish the magic (webClient.waitForBackgroundJavaScript(1000);) >> >>> webClient.getOptions().setThrowExceptionOnScriptError(false); >> Keep also in mind that if a js exception is thrown the js execution is stopped. If you got a js execption, compare with real browsers. If this exception is not thrown in real >> browsers, this might suppress some js code be required to open the popup or send the data. If you have this kind of problems please open an issue. >> >> And as always use the latest SNAPSHOT build. >> >> Hope that helps, if not feel free to provide more details >> >> RBRi > |
From: jp l. <jp....@gm...> - 2017-08-03 19:05:14
|
Hi Ronald thank you very much for your email. It was very very useful. I was blind thinking was a popup. thank you again ! On Thu, Aug 3, 2017 at 8:53 AM, Ronald Brill <rb...@rb...> wrote: > Hi jp list ;-) > > because your code is not complete and there is at least no url i can test with i have to guess a bit and i like to add some hints > > At first - the setup of your web client > Even if stackoverflow today has solutions of everything it is not always a good idea to copy that stuff without knowing what the implications of that code. > The idea of the default setup of the webclient is to configure the client as close as possible to your real browser (because HtmlUnit is designed for application testing there is one > exception of this rule regarding js error handling). > So please start without setting any option and change only the required options on demand > >> webClient.getOptions().setThrowExceptionOnScriptError(false); > This is the one exception of the general rule. But it is a good idea to do this only if you are facing js exceptions. > Keep also in mind that if a js exception is thrown the js execution is stopped. If you got a js execption, compare with real browsers. If this exception is not thrown in real > browsers, this might suppress some js code be required to open the popup or send the data > >> webClient.getOptions().setJavaScriptEnabled(true); > This is already the default. > >> webClient.waitForBackgroundJavaScript(30000); > As i mentioned many times on stackoverflow this is NOT an option, doing this at this place is nonsens. > >> webClient.getOptions().setActiveXNative(true); >> webClient.getOptions().setAppletEnabled(true); > Do you really need ActivX support (you are using the default browser ChromeSimulation at the moment)? > Do you really need Applet support? > >> webClient.getOptions().setCssEnabled(true); > This is already the default. > >> webClient.getOptions().setUseInsecureSSL(true); > This makes sense if you like to address application with invalid certificates. > > > Ok, so far for the setup > >><div class="bootbox modal fade in" tabindex="-1" role="dialog" >>aria-hidden="false" style="display: block; padding-right: 15px;"> >> <div class="modal-backdrop fade in" sHi there. > > Next point is your idea of an popup. You have to understand the way browsers are working. Today browsers are usually using tabs when a new 'window' gets opend. This > might be the result of anchor click with a target. Another option is the use of the javascript open funtions. > But most of the modern applications / frameworks are not doing this. They are doing some 'fake' windowing by placing some gray rectangle on top of your page and than > placing some window look alike html stuff on top of this. Your code sample looks like this solution (usually there is a lot of js/css magic behind to make this happen). > > So forget/remove the window listener stuff from your code. > The dialog is part of your current page. > > In general your code should work like that > * navigate to the start page > * locate the element that opens the dialog > * click the element to open the dialog > * optional: wait a bit to finish the magic (webClient.waitForBackgroundJavaScript(1000);) > * locate the dialog button you like to click from the current page (looks like there is no id - you have to use XPath or iterate over all buttons on the page and select the right one > by checking for e.g. the css class and/or other attributes > * click the button > * optional: wait a bit to finish the magic (webClient.waitForBackgroundJavaScript(1000);) > >> webClient.getOptions().setThrowExceptionOnScriptError(false); > Keep also in mind that if a js exception is thrown the js execution is stopped. If you got a js execption, compare with real browsers. If this exception is not thrown in real > browsers, this might suppress some js code be required to open the popup or send the data. If you have this kind of problems please open an issue. > > And as always use the latest SNAPSHOT build. > > Hope that helps, if not feel free to provide more details > > RBRi |
From: Ronald B. <rb...@rb...> - 2017-08-03 05:54:10
|
Hi jp list ;-) because your code is not complete and there is at least no url i can test with i have to guess a bit and i like to add some hints At first - the setup of your web client Even if stackoverflow today has solutions of everything it is not always a good idea to copy that stuff without knowing what the implications of that code. The idea of the default setup of the webclient is to configure the client as close as possible to your real browser (because HtmlUnit is designed for application testing there is one exception of this rule regarding js error handling). So please start without setting any option and change only the required options on demand > webClient.getOptions().setThrowExceptionOnScriptError(false); This is the one exception of the general rule. But it is a good idea to do this only if you are facing js exceptions. Keep also in mind that if a js exception is thrown the js execution is stopped. If you got a js execption, compare with real browsers. If this exception is not thrown in real browsers, this might suppress some js code be required to open the popup or send the data > webClient.getOptions().setJavaScriptEnabled(true); This is already the default. > webClient.waitForBackgroundJavaScript(30000); As i mentioned many times on stackoverflow this is NOT an option, doing this at this place is nonsens. > webClient.getOptions().setActiveXNative(true); > webClient.getOptions().setAppletEnabled(true); Do you really need ActivX support (you are using the default browser ChromeSimulation at the moment)? Do you really need Applet support? > webClient.getOptions().setCssEnabled(true); This is already the default. > webClient.getOptions().setUseInsecureSSL(true); This makes sense if you like to address application with invalid certificates. Ok, so far for the setup ><div class="bootbox modal fade in" tabindex="-1" role="dialog" >aria-hidden="false" style="display: block; padding-right: 15px;"> > <div class="modal-backdrop fade in" sHi there. Next point is your idea of an popup. You have to understand the way browsers are working. Today browsers are usually using tabs when a new 'window' gets opend. This might be the result of anchor click with a target. Another option is the use of the javascript open funtions. But most of the modern applications / frameworks are not doing this. They are doing some 'fake' windowing by placing some gray rectangle on top of your page and than placing some window look alike html stuff on top of this. Your code sample looks like this solution (usually there is a lot of js/css magic behind to make this happen). So forget/remove the window listener stuff from your code. The dialog is part of your current page. In general your code should work like that * navigate to the start page * locate the element that opens the dialog * click the element to open the dialog * optional: wait a bit to finish the magic (webClient.waitForBackgroundJavaScript(1000);) * locate the dialog button you like to click from the current page (looks like there is no id - you have to use XPath or iterate over all buttons on the page and select the right one by checking for e.g. the css class and/or other attributes * click the button * optional: wait a bit to finish the magic (webClient.waitForBackgroundJavaScript(1000);) > webClient.getOptions().setThrowExceptionOnScriptError(false); Keep also in mind that if a js exception is thrown the js execution is stopped. If you got a js execption, compare with real browsers. If this exception is not thrown in real browsers, this might suppress some js code be required to open the popup or send the data. If you have this kind of problems please open an issue. And as always use the latest SNAPSHOT build. Hope that helps, if not feel free to provide more details RBRi |
From: jp l. <jp....@gm...> - 2017-08-02 23:00:18
|
Hi there. I am trying to reach a button in a popup, but I can't get it ... I try to follow only example that I found in the web ... here is my code, maybe someone face the same and can help me: final LinkedList<WebWindow> windows = new LinkedList<WebWindow>(); try (final WebClient webClient = new WebClient(BrowserVersion.getDefault())) { webClient.setJavaScriptTimeout(5000); webClient.getOptions().setThrowExceptionOnScriptError(false); webClient.getOptions().setJavaScriptEnabled(true); webClient.waitForBackgroundJavaScript(30000); webClient.getOptions().setActiveXNative(true); webClient.getOptions().setAppletEnabled(true); webClient.getOptions().setCssEnabled(true); webClient.getOptions().setUseInsecureSSL(true); webClient.addWebWindowListener(new WebWindowListener() { @Override public void webWindowOpened(WebWindowEvent webWindowEvent) { windows.add(webWindowEvent.getWebWindow()); } @Override public void webWindowContentChanged(WebWindowEvent webWindowEvent) { } @Override public void webWindowClosed(WebWindowEvent webWindowEvent) { } }); //.... code for getting the button that raise the popup HtmlPage popupPage = (HtmlPage) windows.getLast(); // <- this is empty this is the html that raise the popup <input class="btn btn-success btn-lg create_lending_btn" type="submit" value="Lending Offer"> this is the html for the pop up <div class="bootbox modal fade in" tabindex="-1" role="dialog" aria-hidden="false" style="display: block; padding-right: 15px;"> <div class="modal-backdrop fade in" style="height: 954px;"></div> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="bootbox-close-button close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title">Offer Details</h4> </div> <div class="modal-body"> <div class="bootbox-body"> <div> </div> </div> </div> <div class="modal-footer"><button data-bb-handler="cancel" type="button" class="btn btn btn-danger">Cancel</button><button data-bb-handler="confirm" type="button" class="btn btn btn-success">Confirm</button></div> </div> </div> </div> After that the button is executing some Ajax Javascript any ideas ? thank you in advance. |
From: José R. | I. S.L. <jr...@id...> - 2017-07-19 12:54:09
|
Hi, Thanks a lot for your response!. Just a couple of seconds before your mail I managed to do it by using XPath absolute navigation path... (/html/body/div/...). Thanks again El 19 jul. 2017 2:51 p. m., "Albu Gmail" <alb...@gm...> escribió: > DId you try this: > > HtmlForm form = (HtmlForm) page.getByXPath("/html/body/form").get(0); > HtmlTextInput name = form.getInputByName("marca"); > > Anyway first thing to do is test with devtools int he website if it is > correct check javascript error > > And last but not least your best friend is the Firefox extension: > htmlunitscripter > > > > Le 19/07/2017 à 13:52, José Román | Idiria S.L. a écrit : > > Hi!, > > I am trying to get an input element from this web: > > https://www.milanuncios.com/textos-del-anuncio/?demandax= > n&c=131&idlocalidad=8&p=almeria&x=27&y=0 > > The input itself is: > > <input class="inputs campoGrande" name="marca" value="" maxlength="120" size="12" id="marca" tabindex="1" type="text"> > > I have tried different approaches but all I always get is a "null" > reference: > > HtmlInput inputZona = (HtmlInput) currentPage.getElementById("marca"); > HtmlInput inputZona = (HtmlInput) currentPage.getFirstByXPath("//input[@name='marca']"); > > Also tried JSoup with same results :-( > > Both, HTMLUnit and XPAth fail to get the item. > > What is going on with this? > > Thanks in advance, > > > > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > > > > _______________________________________________ > Htmlunit-user mailing lis...@li...https://lists.sourceforge.net/lists/listinfo/htmlunit-user > > > > ------------------------------------------------------------ > ------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > > |
From: Albu G. <alb...@gm...> - 2017-07-19 12:50:57
|
DId you try this: HtmlForm form = (HtmlForm) page.getByXPath("/html/body/form").get(0); HtmlTextInput name = form.getInputByName("marca"); Anyway first thing to do is test with devtools int he website if it is correct check javascript error And last but not least your best friend is the Firefox extension: htmlunitscripter Le 19/07/2017 à 13:52, José Román | Idiria S.L. a écrit : > > Hi!, > > I am trying to get an input element from this web: > > https://www.milanuncios.com/textos-del-anuncio/?demandax=n&c=131&idlocalidad=8&p=almeria&x=27&y=0 > > The input itself is: > > |<inputclass="inputs > campoGrande"name="marca"value=""maxlength="120"size="12"id="marca"tabindex="1"type="text">| > > I have tried different approaches but all I always get is a "null" > reference: > > |HtmlInput inputZona = (HtmlInput) currentPage.getElementById("marca"); > HtmlInput inputZona = (HtmlInput) > currentPage.getFirstByXPath("//input[@name='marca']");| > > Also tried JSoup with same results :-( > > Both, HTMLUnit and XPAth fail to get the item. > > What is going on with this? > > Thanks in advance, > > > > > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > > > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user |
From: José R. | I. S.L. <jr...@id...> - 2017-07-19 12:21:35
|
Hi!, I am trying to get an input element from this web: https://www.milanuncios.com/textos-del-anuncio/?demandax=n&c=131&idlocalidad=8&p=almeria&x=27&y=0 The input itself is: <input class="inputs campoGrande" name="marca" value="" maxlength="120" size="12" id="marca" tabindex="1" type="text"> I have tried different approaches but all I always get is a "null" reference: HtmlInput inputZona = (HtmlInput) currentPage.getElementById("marca"); HtmlInput inputZona = (HtmlInput) currentPage.getFirstByXPath("//input[@name='marca']"); Also tried JSoup with same results :-( Both, HTMLUnit and XPAth fail to get the item. What is going on with this? Thanks in advance, |
From: Albu G. <alb...@gm...> - 2017-07-14 07:10:06
|
Which data are you extracting exactly can yu tell me it could help me to see if it could be a workaround Le 14/07/2017 à 04:36, Xue-Feng Yang a écrit : > I have more progress now. After testing, BrowserVersion Chrome and > FireFox52(or the best supported) can reduce the job count to 2 in 5 > minutes, and the data I needed is in webClient now. The others > (FireFox45, Edge, IE) can't reduce the job count to 2 in 5 minutes and > I can't see the data in webClient when the job count only reduces to 3 > or more. > > It's worth to point out that all real browsers I tested can show the > data in less than one minute. > > Any more suggestion? > > On Thu, Jul 13, 2017 at 12:48 PM, Albu Gmail <alb...@gm... > <mailto:alb...@gm...>> wrote: > > You are really testing my memory man.... > > The idea,(my idea) is there are some timers set in the page (auto > refresh, update or so...) and as it is explained here: > http://www.webdeveloper.com/forum/showthread.php?233448-Is-there-a-way-to-find-if-any-intervals-are-still-open > <http://www.webdeveloper.com/forum/showthread.php?233448-Is-there-a-way-to-find-if-any-intervals-are-still-open> > > *You cannot reliably tell if there are any unnamed intervals > running, but you**can**shut down any that are open.* > > In previous answer You can see a call to a methode call > attendPourJavascriptSaufTimers, for example in : > > // add a fake submit button to be able to submit the form( I > translated from french) > loginForm.appendChild(fauxBouton ); > pageEnCours = fauxBouton.click(); > ///webClient.waitForBackgroundJavaScript(AttentePourJavascript.CINQ_SECONDES.getTempo()); > / *Original call but I got trouble so:* > webClient.attendPourJavascriptSaufTimers(pageEnCours, > AttentePourJavascript.CINQ_SECONDES.getTempo()); > > print.save(NomsFichiersPagesSauvegardees.APRES_LOGGING.getUrl(), > pageEnCours.asXml(), original); //Waiting for 5 seconds but could > return before if nothing is running > > *What this method is doing:* > > public int attendPourJavascriptSaufTimers(HtmlPage page,long tempo){ > > String texteDuScript = > ScriptAExecuter.ANNULE_LES_TIMERS.getScript(); //Use an > enumeration where the scripts are described > Object result = > page.executeJavaScript(texteDuScript).getJavaScriptResult(); > int retour = this.waitForBackgroundJavaScript(tempo); > return retour; > } > > the script executed (ANNULE_LES_TIMERS is the following: > /limit= 10;// > // var np, n= setInterval(function(){},100000);// > // np= Math.max(0, n-limit);// > // while(n> np){// > // clearInterval(n--);// > // } > > //*If I wrote all this stuff it was because I was running into > problems like you are , not getting all the page content I should, > so my advise is to follow a little bit my track...*//*even If I > don't remember all the details*//* > *//*I think also you can see if there are interval set with the > website you are scrapping and DevTools console of your browser*//* > *//*I remember having done these back and forth sessions between > DevTools and htmlunit, you really have to understand completely > what's running on the site if you want to mimic it.*/ > /* > > */ > Le 13/07/2017 à 17:36, Xue-Feng Yang a écrit : >> I made more experiments on the issue. I added the following >> >> webClient.getOptions().setUseInsecureSSL(true); >> webClient.getCookieManager().setCookiesEnabled(true); >> webClient.setAjaxController(new >> NicelyResynchronizingAjaxController()); >> >> JavaScriptJobManager manager = >> htmlPage.getEnclosingWindow().getJobManager(); >> int count = 0; >> while(manager.getJobCount() > 0){ >> System.out.println(count + "@" + manager.getJobCount()); >> webClient.waitForBackgroundJavaScript(10000); >> count ++; >> } >> >> Then I went to sleep. It's been running for a few hours. The job >> count has been changed from 20 to 3 and stayed at 3. >> >> Any thought? >> >> Thanks >> >> On Wed, Jul 12, 2017 at 10:56 PM, Xue-Feng Yang <no...@gm... >> <mailto:no...@gm...>> wrote: >> >> >> Hi, I used htmlunit for getting some other web pages. It >> works great. >> >> However, when I tried >> https://weather.com/weather/monthly/l/27560:4:US >> <https://weather.com/weather/monthly/l/27560:4:US> , I got >> something not correct. >> >> Here are the summary of my system: >> >> OS: win 10 >> Java: jdk1.8.0_131 >> htmlunit: htmlunit-2.27-bin >> >> Attached are three pictures. >> >> eclipse-debug gives the result htmlunit got. The main code is >> as follows: >> >> webClient = new WebClient(BrowserVersion.FIREFOX_45); >> webClient.getOptions().setTimeout(600 * 1000); >> webClient.waitForBackgroundJavaScript(600 * 1000); >> webClient.getOptions().setRedirectEnabled(true); >> webClient.getOptions().setJavaScriptEnabled(true); >> webClient.getOptions().setThrowExceptionOnFailingStatusCode(false); >> webClient.getOptions().setThrowExceptionOnScriptError(false); >> webClient.getOptions().setCssEnabled(false); >> >> htmlPage = webClient.getPage(_url); >> page = htmlPage.asXml(); >> >> view-source is the source page from Firefox. >> >> inspector is the debug tree from Firefox is debugger. >> >> It shows only Firefox debugger has the right html tree. >> >> My question is how to get the html tree by use of htmlunit? >> >> Thanks, >> >> Xuefeng >> >> >> >> >> ------------------------------------------------------------------------------ >> Check out the vibrant tech community on one of the world's most >> engaging tech sites, Slashdot.org!http://sdm.link/slashdot >> >> _______________________________________________ >> Htmlunit-user mailing list >> Htm...@li... >> <mailto:Htm...@li...> >> https://lists.sourceforge.net/lists/listinfo/htmlunit-user >> <https://lists.sourceforge.net/lists/listinfo/htmlunit-user> > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ Htmlunit-user > mailing list Htm...@li... > <mailto:Htm...@li...> > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > <https://lists.sourceforge.net/lists/listinfo/htmlunit-user> > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user |
From: Xue-Feng Y. <xy...@no...> - 2017-07-14 02:36:46
|
I have more progress now. After testing, BrowserVersion Chrome and FireFox52(or the best supported) can reduce the job count to 2 in 5 minutes, and the data I needed is in webClient now. The others (FireFox45, Edge, IE) can't reduce the job count to 2 in 5 minutes and I can't see the data in webClient when the job count only reduces to 3 or more. It's worth to point out that all real browsers I tested can show the data in less than one minute. Any more suggestion? On Thu, Jul 13, 2017 at 12:48 PM, Albu Gmail <alb...@gm...> wrote: > You are really testing my memory man.... > > The idea,(my idea) is there are some timers set in the page (auto refresh, > update or so...) and as it is explained here: http://www.webdeveloper.com/ > forum/showthread.php?233448-Is-there-a-way-to-find-if-any- > intervals-are-still-open > > *You cannot reliably tell if there are any unnamed intervals running, but > you **can **shut down any that are open.* > > In previous answer You can see a call to a methode call > attendPourJavascriptSaufTimers, for example in : > > // add a fake submit button to be able to submit the form( I translated > from french) > loginForm.appendChild(fauxBouton ); > pageEnCours = fauxBouton.click(); > > *//webClient.waitForBackgroundJavaScript(AttentePourJavascript.CINQ_SECONDES.getTempo()); * *Original > call but I got trouble so:* > webClient.attendPourJavascriptSaufTimers(pageEnCours, > AttentePourJavascript.CINQ_SECONDES.getTempo()); > print.save(NomsFichiersPagesSauvegardees.APRES_LOGGING.getUrl(), > pageEnCours.asXml(), original); //Waiting for 5 seconds but could return > before if nothing is running > > *What this method is doing:* > > public int attendPourJavascriptSaufTimers(HtmlPage page,long tempo){ > > String texteDuScript = ScriptAExecuter.ANNULE_LES_TIMERS.getScript(); > //Use an enumeration where the scripts are described > Object result = page.executeJavaScript(texteDuScript). > getJavaScriptResult(); > int retour = this.waitForBackgroundJavaScript(tempo); > return retour; > } > the script executed (ANNULE_LES_TIMERS is the following: > *limit= 10;* > * var np, n= setInterval(function(){},100000);* > * np= Math.max(0, n-limit);* > * while(n> np){* > * clearInterval(n--);* > > > * } **If I wrote all this stuff it was because I was running into > problems like you are , not getting all the page content I should, so my > advise is to follow a little bit my track...**even If I don't remember > all the details* > *I think also you can see if there are interval set with the website you > are scrapping and DevTools console of your browser* > *I remember having done these back and forth sessions between DevTools and > htmlunit, you really have to understand completely what's running on the > site if you want to mimic it.* > > > Le 13/07/2017 à 17:36, Xue-Feng Yang a écrit : > > I made more experiments on the issue. I added the following > > webClient.getOptions().setUseInsecureSSL(true); > webClient.getCookieManager().setCookiesEnabled(true); > webClient.setAjaxController(new NicelyResynchronizingAjaxController()); > > JavaScriptJobManager manager = htmlPage.getEnclosingWindow(). > getJobManager(); > int count = 0; > while(manager.getJobCount() > 0){ > System.out.println(count + "@" + manager.getJobCount()); > webClient.waitForBackgroundJavaScript(10000); > count ++; > } > > Then I went to sleep. It's been running for a few hours. The job count has > been changed from 20 to 3 and stayed at 3. > > Any thought? > > Thanks > > On Wed, Jul 12, 2017 at 10:56 PM, Xue-Feng Yang <no...@gm...> wrote: > >> >> Hi, I used htmlunit for getting some other web pages. It works great. >> >> However, when I tried https://weather.com/weather/monthly/l/27560:4:US , >> I got something not correct. >> >> Here are the summary of my system: >> >> OS: win 10 >> Java: jdk1.8.0_131 >> htmlunit: htmlunit-2.27-bin >> >> Attached are three pictures. >> >> eclipse-debug gives the result htmlunit got. The main code is as follows: >> >> webClient = new WebClient(BrowserVersion.FIREFOX_45); >> webClient.getOptions().setTimeout(600 * 1000); >> webClient.waitForBackgroundJavaScript(600 * 1000); >> webClient.getOptions().setRedirectEnabled(true); >> webClient.getOptions().setJavaScriptEnabled(true); >> webClient.getOptions().setThrowExceptionOnFailingStatusCode( >> false); >> webClient.getOptions().setThrowExceptionOnScriptError(false); >> webClient.getOptions().setCssEnabled(false); >> >> htmlPage = webClient.getPage(_url); >> page = htmlPage.asXml(); >> >> view-source is the source page from Firefox. >> >> inspector is the debug tree from Firefox is debugger. >> >> It shows only Firefox debugger has the right html tree. >> >> My question is how to get the html tree by use of htmlunit? >> >> Thanks, >> >> Xuefeng >> > > > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > > > > _______________________________________________ > Htmlunit-user mailing lis...@li...https://lists.sourceforge.net/lists/listinfo/htmlunit-user > > > > ------------------------------------------------------------ > ------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > > |