line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Selenium::Firefox; |
2
|
|
|
|
|
|
|
$Selenium::Firefox::VERSION = '1.49'; |
3
|
1
|
|
|
1
|
|
605
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
31
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Use FirefoxDriver without a Selenium server |
7
|
1
|
|
|
1
|
|
68
|
use Moo; |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
12
|
|
8
|
1
|
|
|
1
|
|
345
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
117
|
|
9
|
1
|
|
|
1
|
|
9
|
use Selenium::Firefox::Binary qw/firefox_path/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
56
|
|
10
|
|
|
|
|
|
|
use Selenium::CanStartBinary::FindBinary |
11
|
1
|
|
|
1
|
|
5
|
qw/coerce_simple_binary coerce_firefox_binary/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
643
|
|
12
|
|
|
|
|
|
|
extends 'Selenium::Remote::Driver'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has '+browser_name' => ( |
16
|
|
|
|
|
|
|
is => 'ro', |
17
|
|
|
|
|
|
|
default => sub { 'firefox' } |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has 'binary' => ( |
22
|
|
|
|
|
|
|
is => 'lazy', |
23
|
|
|
|
|
|
|
coerce => \&coerce_simple_binary, |
24
|
|
|
|
|
|
|
default => sub { 'geckodriver' }, |
25
|
|
|
|
|
|
|
predicate => 1 |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has 'binary_port' => ( |
30
|
|
|
|
|
|
|
is => 'lazy', |
31
|
|
|
|
|
|
|
default => sub { 9090 } |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
has '_binary_args' => ( |
36
|
|
|
|
|
|
|
is => 'lazy', |
37
|
|
|
|
|
|
|
builder => sub { |
38
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
39
|
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
if ( $self->marionette_enabled ) { |
41
|
0
|
|
|
|
|
|
my $args = |
42
|
|
|
|
|
|
|
' --port ' |
43
|
|
|
|
|
|
|
. $self->port |
44
|
|
|
|
|
|
|
. ' --marionette-port ' |
45
|
|
|
|
|
|
|
. $self->marionette_port |
46
|
|
|
|
|
|
|
. ' --binary "' |
47
|
|
|
|
|
|
|
. $self->firefox_binary . '"'; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
return $args; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
else { |
52
|
0
|
|
|
|
|
|
return ' -no-remote'; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
has '+wd_context_prefix' => ( |
58
|
|
|
|
|
|
|
is => 'ro', |
59
|
|
|
|
|
|
|
default => sub { |
60
|
|
|
|
|
|
|
my ($self) = @_; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
if ( $self->marionette_enabled ) { |
63
|
|
|
|
|
|
|
return ''; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
else { |
66
|
|
|
|
|
|
|
return '/hub'; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
has 'marionette_binary_port' => ( |
74
|
|
|
|
|
|
|
is => 'lazy', |
75
|
|
|
|
|
|
|
default => sub { 2828 } |
76
|
|
|
|
|
|
|
); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
has 'marionette_enabled' => ( |
80
|
|
|
|
|
|
|
is => 'lazy', |
81
|
|
|
|
|
|
|
default => 1 |
82
|
|
|
|
|
|
|
); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
has 'firefox_binary' => ( |
86
|
|
|
|
|
|
|
is => 'lazy', |
87
|
|
|
|
|
|
|
coerce => \&coerce_firefox_binary, |
88
|
|
|
|
|
|
|
predicate => 1, |
89
|
|
|
|
|
|
|
builder => 'firefox_path' |
90
|
|
|
|
|
|
|
); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
has '_execute_script_suffix' => ( |
93
|
|
|
|
|
|
|
is => 'lazy', |
94
|
|
|
|
|
|
|
default => 'Gecko' |
95
|
|
|
|
|
|
|
); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub get_context { |
99
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
100
|
|
|
|
|
|
|
|
101
|
0
|
0
|
|
|
|
|
if ( $self->_is_old_ff ) { |
102
|
0
|
|
|
|
|
|
return 0; |
103
|
|
|
|
|
|
|
} |
104
|
0
|
|
|
|
|
|
my $res = { 'command' => 'getContext' }; |
105
|
0
|
|
|
|
|
|
return $self->_execute_command($res); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub set_context { |
110
|
0
|
|
|
0
|
1
|
|
my ( $self, $context ) = @_; |
111
|
|
|
|
|
|
|
|
112
|
0
|
0
|
|
|
|
|
if ( $self->_is_old_ff ) { |
113
|
0
|
|
|
|
|
|
return 0; |
114
|
|
|
|
|
|
|
} |
115
|
0
|
0
|
|
|
|
|
if ( not defined $context ) { |
116
|
0
|
|
|
|
|
|
croak "Expecting context"; |
117
|
|
|
|
|
|
|
} |
118
|
0
|
0
|
|
|
|
|
if ( $context !~ m/chrome|content/i ) { |
119
|
0
|
|
|
|
|
|
croak "Expecting context value: chrome or content"; |
120
|
|
|
|
|
|
|
} |
121
|
0
|
|
|
|
|
|
my $res = { 'command' => 'setContext' }; |
122
|
0
|
|
|
|
|
|
return $self->_execute_command( $res, { context => $context } ); |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
with 'Selenium::CanStartBinary'; |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
1; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
__END__ |