Guest User

Untitled

a guest
Sep 19th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.87 KB | None | 0 0
  1. WebClient client = new WebClient();
  2. client.getOptions().setCssEnabled(false);
  3. client.getOptions().setJavaScriptEnabled(true);
  4. client.getOptions().setThrowExceptionOnScriptError(false);
  5.  
  6. HtmlPage page = client.getPage(loginUrl);
  7. client.waitForBackgroundJavaScript(30 * 1000);
  8.  
  9. page.executeJavaScript("javascript: {" +
  10. " var arrPostalCodes = new Array();n" +
  11. " arrPostalCodes = ["05001","05002","05003","05004","05005","05140","05160","05192","05194","05195","05196","05197","05289","05520","15001","15002","15003","15004","15005","15006","15007","15008","15009","15010","15011","15100","15102","15105","15106","15107","15108","15109","15125","15130","15139","15140","15141","15142","15144","15145","15146","15147","15148","15151","15154","15155","15160","15165","15166","15168","15169","15171","15172","15173","15174","15175","15176","15177","15178","15179","15180","15181","15182","15189","15190","15191","15198","15199","15200","15210","15211","15212","15213","15220","15228","15229","15270","15280","15281","15296","15300","15310","15314","15315","15316","15318","15319","15320","15325","15326","15327","15328","15329","15337","15340","15347","15350","15357","15380","15388","15401","15402","15403","15404","15405","15406","15490","15500","15530","15540","15541","15554","15555","15563","15567","15568","15569","15570","15572","15578","15582","15590","15592","15593","15594","15595","15596","15597","15600","15607","15609","15613","15614","15615","15616","15620","15621","15622","15623","15624","15627","15630","15637","15638","15639","15640","15650","15659","15660","15668","15669","15670","15679","15690","15701","15702","15703","15704","15705","15706","15707","15781","15782","15820","15830","15864","15866","15881","15883","15884","15885","15886","15890","15892","15893","15894","15895","15896","15897","15898","15940","15950","15959","15960","15965","15966","15967","15969","15970","15980","15993","15994","15999","24001","24002","24003","24004","24005","24006","24007","24008","24009","24010","24100","24110","24111","24112","24113","24114","24138","24139","24140","24141","24191","24193","24195","24196","24197","24198","24226","24228","24231","24390","24391","24395","24400","24401","24402","24403","24404","24410","24411","24412","24413","24414","24415","24416","24490","24491","24492","24496","24497","24498","24540","24548","24549","24700","24710","24711","24713","24715","24717","24718","24794","27001","27002","27003","27004","27141","27150","27153","27154","27160","27161","27192","27230","27290","27293","27294","27297","27298","27330","27340","27350","27375","27376","27377","27378","27379","27400","27424","27430","27460","27500","27510","27511","27512","27513","27514","27515","27516","27517","27518","27519","27520","27527","27528","27529","27530","27531","27532","27533","27540","27550","27554","27555","27556","27557","27558","27559","27595","27596","27700","27710","27711","27712","27713","27714","27715","27740","27742","27747","27748","27749","27752","27770","27774","27775","27776","27777","27778","27779","27780","27785","27786","27787","27788","27789","27790","27791","27792","27793","27794","27796","27797","27798","27800","27810","27811","27812","27814","27815","27816","27818","27820","27821","27822","27823","27824","27825","27826","27830","27832","27833","27834","27835","27836","27840","27841","27842","27843","27850","27860","27863","27864","27866","27867","27868","27869","27880","27888","27890","27892","27893","32001","32002","32003","32004","32005","32170","32300","32310","32313","32314","32315","32316","32317","32318","32336","32340","32348","32350","32356","32358","32420","32456","32500","32510","32514","32515","32516","32523","32534","32539","32570","32572","32573","32574","32575","32600","32613","32615","32616","32618","32619","32620","32626","32627","32630","32631","32632","32634","32635","32636","32637","32640","32641","32643","32644","32650","32692","32695","32696","32697","32698","32699","32710","32890","32911","32960","32981","32990","33812","34001","34002","34003","34004","34005","34006","34190","34192","34200","34220","34419","36001","36002","36003","36004","36005","36163","36164","36201","36202","36203","36204","36205","36206","36207","36208","36209","36210","36211","36212","36213","36214","36215","36300","36307","36308","36309","36310","36311","36312","36315","36316","36317","36318","36320","36340","36350","36360","36370","36378","36379","36380","36388","36389","36390","36391","36392","36393","36400","36410","36411","36412","36413","36414","36415","36416","36417","36418","36419","36440","36448","36450","36455","36456","36457","36458","36460","36470","36471","36472","36473","36474","36475","36500","36510","36511","36512","36514","36515","36516","36517","36518","36519","36579","36584","36588","36596","36598","36600","36610","36611","36612","36613","36614","36615","36616","36617","36618","36619","36620","36658","36659","36676","36680","36681","36682","36683","36684","36685","36686","36687","36688","36689","36700","36710","36711","36712","36713","36714","36715","36720","36721","36729","36730","36740","36790","36791","36840","36860","36861","36862","36863","36864","36865","36866","36867","36868","36869","36870","36890","36891","36892","36893","36895","36900","36910","36930","36939","36940","36954","36955","36958","36959","36960","36966","36967","36969","36970","36980","36990","36991","36992","36993","36995","37001","37002","37003","37004","37005","37006","37007","37008","37120","37181","37184","37185","37188","37189","37193","37194","37439","37796","37900","47001","47002","47003","47004","47005","47006","47007","47008","47009","47010","47011","47012","47013","47014","47015","47016","47130","47140","47151","47155","47193","47194","47195","47220","47400","47450","47454","47460","47463","47465","47490","47491","47492","47493","47494","47500","47509","47610"];n" +
  12. " if (arrPostalCodes && (arrPostalCodes.descripcion === undefined)) {n" +
  13. " arrPostalCodes.unshift({id: '', text: ''});n" +
  14. " }"
  15. + "for (var i in arrPostalCodes) {n" +
  16. " if (typeof arrPostalCodes[i] !== 'object') {n" +
  17. " $(".postalCodesSelect").append($('<option>', {n" +
  18. " value: arrPostalCodes[i],n" +
  19. " text: arrPostalCodes[i]n" +
  20. " })n" +
  21. " );n" +
  22. " }n" +
  23. " }" +
  24. "};");
  25. client.waitForBackgroundJavaScript(30 * 1000);
  26.  
  27. HtmlSelect selectCP = page.getFirstByXPath("//select[@id='cl_postal_code']");
  28. List<HtmlOption> opciones = selectCP.getOptions();
  29. selectCP.setSelectedAttribute(opciones.get(0), true);
  30.  
  31. //get the enclosing form
  32. HtmlForm loginForm = selectCP.getEnclosingForm();
  33.  
  34. //submit the form
  35. page = client.getPage(loginForm.getWebRequest(null));
Add Comment
Please, Sign In to add comment