java - httpunit isn't working when Class extends JFrame -


when attempting login https://www.okcupid.com/login httpunit library, code below executes successfully.

if, however, extend class jframe can build ui, execution fails. post request completes get request fails when executing htmlpage page = wc.getpage(url)

below code have put output both scenarios.

works unless main extends jframe

public class main /* extends jframe */ {     static boolean isconnecting = false;     public static void main(string[] args) {         new main();     }      public main() {         login();     }      public void login() {         try {             /* post */             webclient wc = new webclient();             url url = new url("https://www.okcupid.com/login");             webrequest requestsettings = new webrequest(url, httpmethod.post);             requestsettings.setrequestbody("username=mylogin&password=mypassword&okc_api=1");             page redirectpage = wc.getpage(requestsettings);/* unique */             set<cookie> cookies = wc.getcookiemanager().getcookies();              /*get */             wc = new webclient();             (cookie cookie : cookies) {                 wc.getcookiemanager().addcookie(cookie);             }             htmlpage page = wc.getpage(url);             webresponse response = page.getwebresponse();             string content = response.getcontentasstring();         } catch (ioexception e) {             e.printstacktrace();         }     } } 

output when main extends jframe

connected target vm, address: '127.0.0.1:52571', transport: 'socket' apr 21, 2016 5:31:20 pm com.gargoylesoftware.htmlunit.incorrectnesslistenerimpl notify warning: obsolete content type encountered: 'application/x-javascript'. apr 21, 2016 5:31:20 pm com.gargoylesoftware.htmlunit.javascript.stricterrorreporter runtimeerror severe: runtimeerror: message=[an invalid or illegal selector specified (selector: '*,:x' error: invalid selector: :x).] sourcename=[https://includes.okccdn.com/flat/js/vendor.min.js?v=7a3cb7237dd753a] line=[24] linesource=[null] lineoffset=[0] exception in thread "main" java.lang.stackoverflowerror     @ net.sourceforge.htmlunit.corejs.javascript.regexp.nativeregexp.emitrebytecode(nativeregexp.java:1311)     @ net.sourceforge.htmlunit.corejs.javascript.regexp.nativeregexp.emitrebytecode(nativeregexp.java:1281) . . . . .     // (this repeats on few thousand times before finishing exit code 1.     @ net.sourceforge.htmlunit.corejs.javascript.regexp.nativeregexp.emitrebytecode(nativeregexp.java:131 . . . . . disconnected target vm, address: '127.0.0.1:52571', transport: 'socket'  process finished exit code 1 

output when main not extend jframe

connected target vm, address: '127.0.0.1:52635', transport: 'socket' apr 21, 2016 5:38:29 pm com.gargoylesoftware.htmlunit.incorrectnesslistenerimpl notify warning: obsolete content type encountered: 'application/x-javascript'. apr 21, 2016 5:38:30 pm com.gargoylesoftware.htmlunit.javascript.stricterrorreporter runtimeerror severe: runtimeerror: message=[an invalid or illegal selector specified (selector: '*,:x' error: invalid selector: :x).] sourcename=[https://includes.okccdn.com/flat/js/vendor.min.js?v=7a3cb7237dd753a] line=[24] linesource=[null] lineoffset=[0] apr 21, 2016 5:38:30 pm com.gargoylesoftware.htmlunit.defaultcsserrorhandler error warning: css error: 'https://includes.okccdn.com/lang/en/version/219b51f028bbb87/globals.css' [3:9674] error in style sheet. (invalid token "@charset". expecting 1 of: <eof>, <s>, <ident>, "<!--", "-->", ".", ":", "*", "[", <hash>, <import_sym>, <page_sym>, <media_sym>, <font_face_sym>, <atkeyword>.) apr 21, 2016 5:38:30 pm com.gargoylesoftware.htmlunit.defaultcsserrorhandler error warning: css error: 'https://includes.okccdn.com/lang/en/version/df13e6172aa8212/locals.css?set=home2015,flag_photo' [3:1512] error in expression. (invalid token " ". expecting 1 of: <number>, "inherit", <ident>, <string>, <hash>, <ems>, <exs>, <length_px>, <length_cm>, <length_mm>, <length_in>, <length_pt>, <length_pc>, <angle_deg>, <angle_rad>, <angle_grad>, <time_ms>, <time_s>, <freq_hz>, <freq_khz>, <resolution_dpi>, <resolution_dpcm>, <percentage>, <dimension>, <uri>, <function>.) apr 21, 2016 5:38:30 pm com.gargoylesoftware.htmlunit.defaultcsserrorhandler error warning: css error: 'https://includes.okccdn.com/lang/en/version/df13e6172aa8212/locals.css?set=home2015,flag_photo' [3:1543] error in expression. (invalid token " ". expecting 1 of: <number>, "inherit", <ident>, <string>, <hash>, <ems>, <exs>, <length_px>, <length_cm>, <length_mm>, <length_in>, <length_pt>, <length_pc>, <angle_deg>, <angle_rad>, <angle_grad>, <time_ms>, <time_s>, <freq_hz>, <freq_khz>, <resolution_dpi>, <resolution_dpcm>, <percentage>, <dimension>, <uri>, <function>.) apr 21, 2016 5:38:30 pm com.gargoylesoftware.htmlunit.defaultcsserrorhandler error warning: css error: 'https://includes.okccdn.com/lang/en/version/df13e6172aa8212/locals.css?set=home2015,flag_photo' [3:1566] error in expression. (invalid token " ". expecting 1 of: <number>, "inherit", <ident>, <string>, <hash>, <ems>, <exs>, <length_px>, <length_cm>, <length_mm>, <length_in>, <length_pt>, <length_pc>, <angle_deg>, <angle_rad>, <angle_grad>, <time_ms>, <time_s>, <freq_hz>, <freq_khz>, <resolution_dpi>, <resolution_dpcm>, <percentage>, <dimension>, <uri>, <function>.) apr 21, 2016 5:38:30 pm com.gargoylesoftware.htmlunit.defaultcsserrorhandler error warning: css error: 'https://includes.okccdn.com/lang/en/version/df13e6172aa8212/locals.css?set=home2015,flag_photo' [3:3949] error in expression. (invalid token " ". expecting 1 of: <number>, "inherit", <ident>, <string>, <hash>, <ems>, <exs>, <length_px>, <length_cm>, <length_mm>, <length_in>, <length_pt>, <length_pc>, <angle_deg>, <angle_rad>, <angle_grad>, <time_ms>, <time_s>, <freq_hz>, <freq_khz>, <resolution_dpi>, <resolution_dpcm>, <percentage>, <dimension>, <uri>, <function>.) apr 21, 2016 5:38:30 pm com.gargoylesoftware.htmlunit.defaultcsserrorhandler error warning: css error: 'https://includes.okccdn.com/lang/en/version/df13e6172aa8212/locals.css?set=home2015,flag_photo' [3:3982] error in expression. (invalid token " ". expecting 1 of: <number>, "inherit", <ident>, <string>, <hash>, <ems>, <exs>, <length_px>, <length_cm>, <length_mm>, <length_in>, <length_pt>, <length_pc>, <angle_deg>, <angle_rad>, <angle_grad>, <time_ms>, <time_s>, <freq_hz>, <freq_khz>, <resolution_dpi>, <resolution_dpcm>, <percentage>, <dimension>, <uri>, <function>.) apr 21, 2016 5:38:30 pm com.gargoylesoftware.htmlunit.defaultcsserrorhandler error warning: css error: 'https://includes.okccdn.com/lang/en/version/df13e6172aa8212/locals.css?set=home2015,flag_photo' [3:4007] error in expression. (invalid token " ". expecting 1 of: <number>, "inherit", <ident>, <string>, <hash>, <ems>, <exs>, <length_px>, <length_cm>, <length_mm>, <length_in>, <length_pt>, <length_pc>, <angle_deg>, <angle_rad>, <angle_grad>, <time_ms>, <time_s>, <freq_hz>, <freq_khz>, <resolution_dpi>, <resolution_dpcm>, <percentage>, <dimension>, <uri>, <function>.)  . . . . . . . . .  , on, , forth . . . . . . . <!doctype html>     desired html response string </html> . .  // after connecting successfully, following continues output every 30 seconds apr 21, 2016 5:39:00 pm com.gargoylesoftware.htmlunit.incorrectnesslistenerimpl notify warning: expected content type of 'application/javascript' or 'application/ecmascript' remotely loaded javascript element @ 'https://1-instant.okcupid.com/instantevents?random=0.437989956299249', got 'text/html'. apr 21, 2016 5:39:29 pm com.gargoylesoftware.htmlunit.incorrectnesslistenerimpl notify warning: expected content type of 'application/javascript' or 'application/ecmascript' remotely loaded javascript element @ 'https://2-instant.okcupid.com/instantevents?random=0.4299430644437371&server_seqid=0&server_gmt=1461274740', got 'text/html'. 

i figured out why happening , way around still don't know how make work extending jframe.

  1. if you're using htmlunit handle url requests, first remove jframe extension. code execute still not launch ui.

  2. instead of using class's extension jframe, in part you'll need extension, create new jframe instance. use instance of jframe declare necessary properties , actions.


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -