ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent-WebDriver/WebDriver.pm
(Generate patch)

Comparing AnyEvent-WebDriver/WebDriver.pm (file contents):
Revision 1.24 by root, Wed Aug 29 08:28:19 2018 UTC vs.
Revision 1.25 by root, Wed Aug 29 10:12:29 2018 UTC

72sub req_ { 72sub req_ {
73 my ($self, $method, $ep, $body, $cb) = @_; 73 my ($self, $method, $ep, $body, $cb) = @_;
74 74
75 AnyEvent::HTTP::http_request $method => "$self->{_ep}$ep", 75 AnyEvent::HTTP::http_request $method => "$self->{_ep}$ep",
76 body => $body, 76 body => $body,
77 $self->{persistent} ? (persistent => 1) : (),
78 $self->{proxy} eq "default" ? () : (proxy => $self->{proxy}),
77 timeout => $self->{timeout}, 79 timeout => $self->{timeout},
78 headers => { "content-type" => "application/json; charset=utf-8", "cache-control" => "no-cache" }, 80 headers => { "content-type" => "application/json; charset=utf-8", "cache-control" => "no-cache" },
79 ($self->{proxy} eq "default" ? () : (proxy => $self->{proxy})),
80 sub { 81 sub {
81 my ($res, $hdr) = @_; 82 my ($res, $hdr) = @_;
82 83
83 $res = eval { $json->decode ($res) }; 84 $res = eval { $json->decode ($res) };
84 $hdr->{Status} = 500 unless exists $res->{value}; 85 $hdr->{Status} = 500 unless exists $res->{value};
181The HTTP timeout, in (fractional) seconds (default: C<300>, but this will 182The HTTP timeout, in (fractional) seconds (default: C<300>, but this will
182likely drastically reduce). This timeout is reset on any activity, so it 183likely drastically reduce). This timeout is reset on any activity, so it
183is not an overall request timeout. Also, individual requests might extend 184is not an overall request timeout. Also, individual requests might extend
184this timeout if they are known to take longer. 185this timeout if they are known to take longer.
185 186
187=item persistent => C<1> | C<undef>
188
189If true (the default) then persistent connections will be used for all
190requests, which assumes you have a reasonably stable connection (such as
191to C<localhost> :) and that the WebDriver has a persistent timeout much
192higher than what L<AnyEvent::HTTP> uses.
193
194You can force connections to be closed for non-idempotent requests by
195setting this to C<undef>.
196
186=back 197=back
187 198
188=cut 199=cut
189 200
190sub new { 201sub new {
191 my ($class, %kv) = @_; 202 my ($class, %kv) = @_;
192 203
193 bless { 204 bless {
194 endpoint => "http://localhost:4444", 205 endpoint => "http://localhost:4444",
195 proxy => undef, 206 proxy => undef,
207 persistent => 1,
196 autodelete => 1, 208 autodelete => 1,
197 timeout => 300, 209 timeout => 300,
198 %kv, 210 %kv,
199 }, $class 211 }, $class
200} 212}
326 "moz:firefoxOptions" => { 338 "moz:firefoxOptions" => {
327 binary => "firefox/firefox", 339 binary => "firefox/firefox",
328 args => ["-devtools"], 340 args => ["-devtools"],
329 prefs => { 341 prefs => {
330 "dom.webnotifications.enabled" => \0, 342 "dom.webnotifications.enabled" => \0,
343 "dom.push.enabled" => \0,
331 "dom.disable_beforeunload" => \1, 344 "dom.disable_beforeunload" => \1,
332 "browser.link.open_newwindow" => 3, 345 "browser.link.open_newwindow" => 3,
333 "browser.link.open_newwindow.restrictions" => 0, 346 "browser.link.open_newwindow.restrictions" => 0,
334 "dom.popup_allowed_events" => "", 347 "dom.popup_allowed_events" => "",
335 "dom.disable_open_during_load" => \1, 348 "dom.disable_open_during_load" => \1,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines