javascript - casperjs (phantomjs) unable to submit form after website update -
i've had script running while until after website update.
what doing filling form, clicking submit , scraping results.
now seems no matter do, click, send enter key.. etc form won't submit.
i have following debug lines casper:
casperjs casper1.js [info] [phantom] starting... [info] [phantom] running suite: 4 steps [debug] [phantom] opening url: https://www.vicroads.vic.gov.au/registration/buy-sell-or-transfer-a-vehicle/buy-a-vehicle/check-vehicle-registration/vehicle-registration-enquiry, http [debug] [phantom] navigation requested: url=https://www.vicroads.vic.gov.au/registration/buy-sell-or-transfer-a-vehicle/buy-a-vehicle/check-vehicle-registration/vehicle-registration-enquiry, type=other, willnavigate=true, ismainframe=true [debug] [phantom] url changed "https://www.vicroads.vic.gov.au/registration/buy-sell-or-transfer-a-vehicle/buy-a-vehicle/check-vehicle-registration/vehicle-registration-enquiry" [debug] [phantom] injected casper client-side utilities [info] [phantom] step anonymous 2/4 https://www.vicroads.vic.gov.au/registration/buy-sell-or-transfer-a-vehicle/buy-a-vehicle/check-vehicle-registration/vehicle-registration-enquiry (http 200) [info] [phantom] step anonymous 2/4: done in 1579ms. [info] [phantom] step _step 3/5 https://www.vicroads.vic.gov.au/registration/buy-sell-or-transfer-a-vehicle/buy-a-vehicle/check-vehicle-registration/vehicle-registration-enquiry (http 200) [info] [phantom] step _step 3/5: done in 1599ms. [info] [phantom] waitfor() finished in 40ms. [info] [phantom] step anonymous 4/5 https://www.vicroads.vic.gov.au/registration/buy-sell-or-transfer-a-vehicle/buy-a-vehicle/check-vehicle-registration/vehicle-registration-enquiry (http 200) [debug] [phantom] mouse event 'mousedown' on selector: form#form1 [debug] [phantom] mouse event 'mouseup' on selector: form#form1 [debug] [phantom] mouse event 'click' on selector: form#form1 [info] [phantom] step anonymous 4/5: done in 1691ms. [info] [phantom] step anonymous 5/5 https://www.vicroads.vic.gov.au/registration/buy-sell-or-transfer-a-vehicle/buy-a-vehicle/check-vehicle-registration/vehicle-registration-enquiry (http 200) [debug] [phantom] capturing page /var/www/html/poc/phantom/test.png [info] [phantom] capture saved /var/www/html/poc/phantom/test.png [info] [phantom] step anonymous 5/5: done in 1964ms. [info] [phantom] done 5 steps in 1967ms [debug] [phantom] capturing page /var/www/html/poc/phantom/test0.png [info] [phantom] capture saved /var/www/html/poc/phantom/test0.png [debug] [phantom] navigation requested: url=about:blank, type=other, willnavigate=true, ismainframe=true [debug] [phantom] url changed "about:blank"
var casper = require('casper').create({ verbose: true, useragent: 'mozilla/5.0 (x11; cros x86_64 8172.45.0) applewebkit/537.36 (khtml, gecko) chrome/51.0.2704.64 safari/537.36', xssauditingenabled: false, loglevel: 'debug', javascriptenabled:'false', viewportsize: { width: 1280, height: 720 }, pagesettings: { ignoresslerrors: true, loadimages: false, // not load images loadplugins: false, // not load npapi plugins (flash, silverlight, ...) websecurityenabled: false, localtoremoteurlaccessenabled: false } }); casper.start('https://www.vicroads.vic.gov.au/registration/buy-sell-or-transfer-a-vehicle/buy-a-vehicle/check-vehicle-registration/vehicle-registration-enquiry', function() { // wait form this.waitforselector('form#form1'); }); casper.then(function() { // fill form this.fill('form#form1', { "ph_pagebody_0$phthreecolumnmaincontent_0$panel$vehiclesearch$registrationnumbercar$registrationnumber_ctrlholderdivshown": "zjd402" }, false); this.click('form#form1'); }); casper.then(function() { this.capture('test.png'); }); casper.run(function() { // dump this.capture('test0.png'); //this.debugpage(); this.exit(); });
i have tried waiting selector containing results, never arrives.
any phantomjs / casperjs gurus have tricks sleeves?
you not clicking submit button, entire form.
this.click('form#form1');
a formulary not button, not "clickable". should submit button , click it. in case right this:
this.click('"#main input[type='submit']"');
and that's it.
with 'form#form1'
thinghy looking submit
, don't think calling submit
directly on form trigger onclick
events attached button, if want simulate user actions 100%, better click button directly submitting form.
to submit form directly, remove false
attribute @ end of fill
method.
Comments
Post a Comment