| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Brownie::Driver; |
|
2
|
|
|
|
|
|
|
|
|
3
|
19
|
|
|
19
|
|
5781
|
use strict; |
|
|
19
|
|
|
|
|
47
|
|
|
|
19
|
|
|
|
|
1673
|
|
|
4
|
19
|
|
|
19
|
|
289
|
use warnings; |
|
|
19
|
|
|
|
|
37
|
|
|
|
19
|
|
|
|
|
1675
|
|
|
5
|
19
|
|
|
19
|
|
9328
|
use Sub::Install; |
|
|
19
|
|
|
|
|
19122
|
|
|
|
19
|
|
|
|
|
1037
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
19
|
|
|
19
|
|
12325
|
use Brownie::Helpers; |
|
|
19
|
|
|
|
|
46
|
|
|
|
19
|
|
|
|
|
3024
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
|
10
|
20
|
|
|
20
|
1
|
181
|
my ($class, %args) = @_; |
|
11
|
20
|
|
|
|
|
199
|
return bless { %args }, $class; |
|
12
|
|
|
|
|
|
|
} |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
for my $method (qw/ |
|
15
|
|
|
|
|
|
|
browser |
|
16
|
|
|
|
|
|
|
find |
|
17
|
|
|
|
|
|
|
all |
|
18
|
|
|
|
|
|
|
visit |
|
19
|
|
|
|
|
|
|
current_url |
|
20
|
|
|
|
|
|
|
current_path |
|
21
|
|
|
|
|
|
|
status_code |
|
22
|
|
|
|
|
|
|
response_headers |
|
23
|
|
|
|
|
|
|
title |
|
24
|
|
|
|
|
|
|
source |
|
25
|
|
|
|
|
|
|
screenshot |
|
26
|
|
|
|
|
|
|
execute_script |
|
27
|
|
|
|
|
|
|
evaluate_script |
|
28
|
|
|
|
|
|
|
/) { |
|
29
|
|
|
|
|
|
|
next if __PACKAGE__->can($method); |
|
30
|
|
|
|
|
|
|
Sub::Install::install_sub({ |
|
31
|
|
|
|
|
|
|
code => Brownie::Helpers->can('not_implemented'), |
|
32
|
|
|
|
|
|
|
as => $method, |
|
33
|
|
|
|
|
|
|
}); |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 NAME |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Brownie::Driver - base class of Brownie::Driver series |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 METHODS |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=over 4 |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=item * C |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Returns a new instance. |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my $driver = Brownie::Driver->new(%args); |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=item * C |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Returns a driver specific browser object. |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
my $browser = $driver->browser; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=item * C |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Go to $url. |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
$driver->visit('http://example.com/'); |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=item * C |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Returns current page's URL. |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my $url = $driver->current_url; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item * C |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Returns current page's path of URL. |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
my $path = $driver->current_path; |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=item * C |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Returns last request's HTTP status code. |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my $code = $driver->status_code; |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item * C |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Returns last request's HTTP response headers L. |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
my $headers = $driver->response_headers; |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item * C |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Returns current page's text. |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
my $title = $driver->title; |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item * C |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Returns current page's HTML source. |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
my $source = $driver->source; |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item * C |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Returns current page's HTML root element. |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
my $element = $driver->document; |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item * C |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Takes current page's screenshot and saves to $filename as PNG. |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
$driver->screenshot($filename); |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item * C |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Executes snippet of JavaScript into current page. |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
$driver->execute_script('$("body").empty()'); |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item * C |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Executes snipptes and returns result. |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
my $result = $driver->evaluate_script('1 + 2'); |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
If specified DOM element, it returns WebElement object. |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
my $node = $driver->evaluate_script('document.getElementById("foo")'); |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item * C |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Find an element on the page, and return L object. |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
my $element = $driver->find($locator, %args) |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
C<$locator> is string of "CSS Selector" (e.g. "#id") or "XPath" (e.g. "//a[1]"). |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
C<%args> are: |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=over 8 |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=item * C<-base>: Brownie::Node object where you want to start finding |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
my $parent = $driver->find('#where_to_parent'); |
|
143
|
|
|
|
|
|
|
my $child = $driver->find('a', base => $parent); |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=back |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=item * C |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Find all elements on the page, and return L object list. |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
my @elements = $driver->all($locator, %args) |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
C<$locator> is string of "CSS Selector" (e.g. "#id") or "XPath" (e.g. "//a[1]"). |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
C<%args> are: |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=over 8 |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=item * C<-base>: Brownie::Node object where you want to start finding |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
my $parent = $driver->find('#where_to_parent'); |
|
162
|
|
|
|
|
|
|
my @children = $driver->all('li', base => $parent); |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=back |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=back |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 AUTHOR |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
NAKAGAWA Masaki Emasaki@cpan.orgE |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 LICENSE |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
175
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
L, L |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=cut |