Selenium/Chrome.pm

filter: Statementstmt 74.0% 20 / 27 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 4 / 8 Podpod n/a totaltotal 68.5% 24 / 35 SCAR 0.2
CC
1
Cov
74%
__ANON__
2.0
__ANON__
2.0
__ANON__
2.0
CRAP 1.0
« Selenium/Edge.pm ↑ Summary Selenium/PhantomJS.pm »
1 package Selenium::Chrome;
2 3 $Selenium::Chrome::VERSION = '1.49';
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 # ABSTRACT: Use ChromeDriver without a Selenium server
7 3 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Selenium::CanStartBinary::FindBinary qw/coerce_simple_binary/;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 extends 'Selenium::Remote::Driver';
10  
11  
12 has '+browser_name' => (
13 is => 'ro',
14 0 ▶ default => sub { 'chrome' }
Subroutine __ANON__: not called CC=1 SCAR=6.9
15 3 );
16  
17  
18 has 'binary' => (
19 is => 'lazy',
20 coerce => \&coerce_simple_binary,
21 0 ▶ default => sub { 'chromedriver' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
22 3 predicate => 1
23 );
24  
25  
26 has 'binary_port' => (
27 is => 'lazy',
28 0 ▶ default => sub { 9515 }
Subroutine __ANON__: not called CC=1 SCAR=6.9
29 3 );
30  
31 has '_binary_args' => (
32 is => 'lazy',
33 builder => sub {
34 0 ▶ my ($self) = @_;
Subroutine _build__binary_args: not called CC=1 SCAR=6.9
35  
36 0 my $context = $self->wd_context_prefix;
37 0 $context =~ s{^/}{};
38  
39 0 return ' --port=' . $self->port . ' --url-base=' . $context . ' ';
40 }
41 3 );
42  
43 3 with 'Selenium::CanStartBinary';
44  
45  
46 3 1;
47  
48 __END__
49  
50 =pod
51  
52 =encoding UTF-8
53  
54 =head1 NAME
55  
56 Selenium::Chrome - Use ChromeDriver without a Selenium server
57  
58 =head1 VERSION
59  
60 version 1.49
61  
62 =head1 SYNOPSIS
63  
64 my $driver = Selenium::Chrome->new;
65 # when you're done
66 $driver->shutdown_binary;
67  
68 =head1 DESCRIPTION
69  
70 This class allows you to use the ChromeDriver without needing the JRE
71 or a selenium server running. When you refrain from passing the
72 C<remote_server_addr> and C<port> arguments, we will search for the
73 chromedriver executable binary in your $PATH. We'll try to start the
74 binary connect to it, shutting it down at the end of the test.
75  
76 If the chromedriver binary is not found, we'll fall back to the
77 default L<Selenium::Remote::Driver> behavior of assuming defaults of
78 127.0.0.1:4444 after waiting a few seconds.
79  
80 If you specify a remote server address, or a port, we'll assume you
81 know what you're doing and take no additional behavior.
82  
83 If you're curious whether your Selenium::Chrome instance is using a
84 separate ChromeDriver binary, or through the selenium server, you can
85 check the C<binary_mode> attr after instantiation.
86  
87 =head1 ATTRIBUTES
88  
89 =head2 binary
90  
91 Optional: specify the path to your binary. If you don't specify
92 anything, we'll try to find it on our own via L<File::Which/which>.
93  
94 =head2 binary_port
95  
96 Optional: specify the port that we should bind to. If you don't
97 specify anything, we'll default to the driver's default port. Since
98 there's no a priori guarantee that this will be an open port, this is
99 _not_ necessarily the port that we end up using - if the port here is
100 already bound, we'll search above it until we find an open one.
101  
102 See L<Selenium::CanStartBinary/port> for more details, and
103 L<Selenium::Remote::Driver/port> after instantiation to see what the
104 actual port turned out to be.
105  
106 =head2 custom_args
107  
108 Optional: specify any additional command line arguments you'd like
109 invoked during the binary startup. See
110 L<Selenium::CanStartBinary/custom_args> for more information.
111  
112 =head2 startup_timeout
113  
114 Optional: specify how long to wait for the binary to start itself and
115 listen on its port. The default duration is arbitrarily 10 seconds. It
116 accepts an integer number of seconds to wait: the following will wait
117 up to 20 seconds:
118  
119 Selenium::Chrome->new( startup_timeout => 20 );
120  
121 See L<Selenium::CanStartBinary/startup_timeout> for more information.
122  
123 =head2 fixed_ports
124  
125 Optional: Throw instead of searching for additional ports; see
126 L<Selenium::CanStartBinary/fixed_ports> for more info.
127  
128 =head1 METHODS
129  
130 =head2 shutdown_binary
131  
132 Call this method instead of L<Selenium::Remote::Driver/quit> to ensure
133 that the binary executable is also closed, instead of simply closing
134 the browser itself. If the browser is still around, it will call
135 C<quit> for you. After that, it will try to shutdown the browser
136 binary by making a GET to /shutdown and on Windows, it will attempt to
137 do a C<taskkill> on the binary CMD window.
138  
139 $self->shutdown_binary;
140  
141 It doesn't take any arguments, and it doesn't return anything.
142  
143 We do our best to call this when the C<$driver> option goes out of
144 scope, but if that happens during global destruction, there's nothing
145 we can do.
146  
147 =for Pod::Coverage has_binary
148  
149 =head1 AUTHORS
150  
151 Current Maintainers:
152  
153 =over 4
154  
155 =item *
156  
157 George S. Baugh <george@troglodyne.net>
158  
159 =back
160  
161 Previous maintainers:
162  
163 =over 4
164  
165 =item *
166  
167 Daniel Gempesaw <gempesaw@gmail.com>
168  
169 =item *
170  
171 Emmanuel Peroumalnaïk <peroumalnaik.emmanuel@gmail.com>
172  
173 =item *
174  
175 Luke Closs <cpan@5thplane.com>
176  
177 =item *
178  
179 Mark Stosberg <mark@stosberg.com>
180  
181 =back
182  
183 Original authors:
184  
185 =over 4
186  
187 =item *
188  
189 Aditya Ivaturi <ivaturi@gmail.com>
190  
191 =back
192  
193 =head1 COPYRIGHT AND LICENSE
194  
195 Copyright (c) 2010-2011 Aditya Ivaturi, Gordon Child
196  
197 Copyright (c) 2014-2017 Daniel Gempesaw
198  
199 Copyright (c) 2018-2021 George S. Baugh
200  
201 Licensed under the Apache License, Version 2.0 (the "License");
202 you may not use this file except in compliance with the License.
203 You may obtain a copy of the License at
204  
205 http://www.apache.org/licenses/LICENSE-2.0
206  
207 Unless required by applicable law or agreed to in writing, software
208 distributed under the License is distributed on an "AS IS" BASIS,
209 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
210 See the License for the specific language governing permissions and
211 limitations under the License.
212  
213 =cut
« Selenium/Edge.pm ↑ Summary Selenium/PhantomJS.pm »