in reply to Re^2: POST in WWW::Mechanize::PhantomJS
in thread POST in WWW::Mechanize::PhantomJS

Did you try to POST something yourself, by chance?

Nope, the test suite doesn't run well for me at all (my windows is probably too old)

Been there, done that, got the scar. :)

:?) But did you UTSL :?)

https://metacpan.org/pod/WWW::Mechanize::PhantomJS#Functions-that-will-likely-never-be-implemented

Functions that will likely never be implemented ->post I have no use for it ... sub post {
my ($self, $url, %options) = @_; #my $b = $self->tab->{linkedBrowser}; $self->clear_current_form; #my $flags = 0; #if ($options{no_cache}) { # $flags = $self->repl->constant('nsIWebNavigation.LOAD_FLAGS_BYP +ASS_CACHE'); #}; # If we don't have data, encode the parameters: if( !$options{ data }) { my $req= HTTP::Request::Common::POST( $url, $options{params} ) +; #warn $req->content; carp "Faking content from parameters is not yet supported."; #$options{ data } = $req->content; }; #$options{ charset } ||= 'utf-8'; #$options{ headers } ||= {}; #$options{ headers }->{"Content-Type"} ||= "application/x-www-form +-urlencoded"; #if( $options{ charset }) { # $options{ headers }->{"Content-Type"} .= "; charset=$options{ + charset }"; #}; # Javascript POST implementation taken from # http://stackoverflow.com/questions/133925/javascript-post-reques +t-like-a-form-submit $self->eval(<<'JS', $url, $options{ params }, 'POST'); function (path, params, method) { method = method || "post"; // Set method to post by defaul +t if not specified. // The rest of this code assumes you are not using a libra +ry. // It can be made less wordy if you use one. var form = document.createElement("form"); form.setAttribute("method", method); form.setAttribute("action", path); for(var key in params) { if(params.hasOwnProperty(key)) { var hiddenField = document.createElement("input"); hiddenField.setAttribute("type", "hidden"); hiddenField.setAttribute("name", key); hiddenField.setAttribute("value", params[key]); form.appendChild(hiddenField); } } document.body.appendChild(form); form.submit(); } JS
# Now, how to trick Selenium into fetching the response? }
https://metacpan.org/source/CORION/WWW-Mechanize-PhantomJS-0.03/t/50-mech-post.t
plan skip_all => "POST requests via Selenium/ghostdriver/PhantomJS + are currently unsupported :-/";

Replies are listed 'Best First'.
Re^4: POST in WWW::Mechanize::PhantomJS
by pghilb (Novice) on Jul 20, 2014 at 10:29 UTC
    Right you are, eventually one comes down to that. :) Cheers,