| 1 | package Test::WWW::Selenium::HTML; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 10 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 10 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 10 | ▶ | use Params::Validate qw(validate validate_pos SCALAR HASHREF); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 10 | ▶ | use Test::More; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 10 | ▶ | use Test::Builder; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 10 | ▶ | use Time::HiRes qw(sleep); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 10 | ▶ | use XML::LibXML; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | # Accessors that do not take a locator as an argument. | ||||||||||||||||||||||||||||||||||||||||||
| 13 | 10 | ▶ | use constant NO_LOCATOR => | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 10 | { map { $_ => 1 } | |||||||||||||||||||||||||||||||||||||||||
| 15 | qw(Alert | ||||||||||||||||||||||||||||||||||||||||||
| 16 | AlertPresent | ||||||||||||||||||||||||||||||||||||||||||
| 17 | AllButtons | ||||||||||||||||||||||||||||||||||||||||||
| 18 | AllFields | ||||||||||||||||||||||||||||||||||||||||||
| 19 | AllLinks | ||||||||||||||||||||||||||||||||||||||||||
| 20 | BodyText | ||||||||||||||||||||||||||||||||||||||||||
| 21 | HtmlSource | ||||||||||||||||||||||||||||||||||||||||||
| 22 | Confirmation | ||||||||||||||||||||||||||||||||||||||||||
| 23 | Location | ||||||||||||||||||||||||||||||||||||||||||
| 24 | Prompt | ||||||||||||||||||||||||||||||||||||||||||
| 25 | 10 | Title) }; | |||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | # Accessors that store single values (strings, numbers). | ||||||||||||||||||||||||||||||||||||||||||
| 28 | 10 | ▶ | use constant VALUE_STORES => | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 10 | { map { $_ => 1 } | |||||||||||||||||||||||||||||||||||||||||
| 30 | qw(Attribute | ||||||||||||||||||||||||||||||||||||||||||
| 31 | Alert | ||||||||||||||||||||||||||||||||||||||||||
| 32 | BodyText | ||||||||||||||||||||||||||||||||||||||||||
| 33 | Confirmation | ||||||||||||||||||||||||||||||||||||||||||
| 34 | Cookie | ||||||||||||||||||||||||||||||||||||||||||
| 35 | CursorPosition | ||||||||||||||||||||||||||||||||||||||||||
| 36 | ElementWidth | ||||||||||||||||||||||||||||||||||||||||||
| 37 | ElementHeight | ||||||||||||||||||||||||||||||||||||||||||
| 38 | ElementIndex | ||||||||||||||||||||||||||||||||||||||||||
| 39 | ElementPositionLeft | ||||||||||||||||||||||||||||||||||||||||||
| 40 | ElementPositionTop | ||||||||||||||||||||||||||||||||||||||||||
| 41 | Eval | ||||||||||||||||||||||||||||||||||||||||||
| 42 | Expression | ||||||||||||||||||||||||||||||||||||||||||
| 43 | HtmlSource | ||||||||||||||||||||||||||||||||||||||||||
| 44 | Location | ||||||||||||||||||||||||||||||||||||||||||
| 45 | Prompt | ||||||||||||||||||||||||||||||||||||||||||
| 46 | SelectedId | ||||||||||||||||||||||||||||||||||||||||||
| 47 | SelectedIndex | ||||||||||||||||||||||||||||||||||||||||||
| 48 | SelectedLabel | ||||||||||||||||||||||||||||||||||||||||||
| 49 | SelectedValue | ||||||||||||||||||||||||||||||||||||||||||
| 50 | Table | ||||||||||||||||||||||||||||||||||||||||||
| 51 | Text | ||||||||||||||||||||||||||||||||||||||||||
| 52 | Title | ||||||||||||||||||||||||||||||||||||||||||
| 53 | Value | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 10 | WhetherThisFrameMatchFrameExpression) }; | |||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | # Accessors that store an array of values. | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 10 | ▶ | use constant ARRAY_VALUE_STORES => | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 10 | { map { $_ => 1 } | |||||||||||||||||||||||||||||||||||||||||
| 59 | qw(AllButtons | ||||||||||||||||||||||||||||||||||||||||||
| 60 | AllFields | ||||||||||||||||||||||||||||||||||||||||||
| 61 | AllLinks | ||||||||||||||||||||||||||||||||||||||||||
| 62 | AllWindowIds | ||||||||||||||||||||||||||||||||||||||||||
| 63 | AllWindowNames | ||||||||||||||||||||||||||||||||||||||||||
| 64 | AllWindowTitles | ||||||||||||||||||||||||||||||||||||||||||
| 65 | AttributeFromAllWindows | ||||||||||||||||||||||||||||||||||||||||||
| 66 | LogMessages | ||||||||||||||||||||||||||||||||||||||||||
| 67 | SelectedIds | ||||||||||||||||||||||||||||||||||||||||||
| 68 | SelectedIndexes | ||||||||||||||||||||||||||||||||||||||||||
| 69 | SelectedLabels | ||||||||||||||||||||||||||||||||||||||||||
| 70 | SelectedValues | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 10 | SelectOptions) }; | |||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | # Accessors that store a boolean value. | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 10 | ▶ | use constant BOOL_VALUE_STORES => | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 10 | { map { $_ => 1 } | |||||||||||||||||||||||||||||||||||||||||
| 76 | qw(AlertPresent | ||||||||||||||||||||||||||||||||||||||||||
| 77 | AlertNotPresent | ||||||||||||||||||||||||||||||||||||||||||
| 78 | Checked | ||||||||||||||||||||||||||||||||||||||||||
| 79 | NotChecked | ||||||||||||||||||||||||||||||||||||||||||
| 80 | ConfirmationPresent | ||||||||||||||||||||||||||||||||||||||||||
| 81 | ConfirmationNotPresent | ||||||||||||||||||||||||||||||||||||||||||
| 82 | Editable | ||||||||||||||||||||||||||||||||||||||||||
| 83 | NotEditable | ||||||||||||||||||||||||||||||||||||||||||
| 84 | ElementPresent | ||||||||||||||||||||||||||||||||||||||||||
| 85 | ElementNotPresent | ||||||||||||||||||||||||||||||||||||||||||
| 86 | Ordered | ||||||||||||||||||||||||||||||||||||||||||
| 87 | NotOrdered | ||||||||||||||||||||||||||||||||||||||||||
| 88 | PromptPresent | ||||||||||||||||||||||||||||||||||||||||||
| 89 | PromptNotPresent | ||||||||||||||||||||||||||||||||||||||||||
| 90 | SomethingSelected | ||||||||||||||||||||||||||||||||||||||||||
| 91 | NotSomethingSelected | ||||||||||||||||||||||||||||||||||||||||||
| 92 | TextPresent | ||||||||||||||||||||||||||||||||||||||||||
| 93 | TextNotPresent | ||||||||||||||||||||||||||||||||||||||||||
| 94 | Visible | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 10 | NotVisible) }; | |||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | # All accessors. | ||||||||||||||||||||||||||||||||||||||||||
| 98 | 10 | ▶ | use constant STORES => | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 580 | { map { $_ => 1 } | |||||||||||||||||||||||||||||||||||||||||
| 100 | 10 | keys %{VALUE_STORES()}, | |||||||||||||||||||||||||||||||||||||||||
| 101 | 10 | keys %{ARRAY_VALUE_STORES()}, | |||||||||||||||||||||||||||||||||||||||||
| 102 | 10 | keys %{BOOL_VALUE_STORES()} }; | |||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 10 | our $VERSION = '0.02'; | |||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | sub new | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 3 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 109 | 3 | my ($selenium) = validate_pos(@_, { isa => 'Test::WWW::Selenium' }); | |||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | 3 | my $test = Test::Builder->new; | |||||||||||||||||||||||||||||||||||||||||
| 112 | 3 | $test->exported_to(__PACKAGE__); | |||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | 3 | my $self = { selenium => $selenium, | |||||||||||||||||||||||||||||||||||||||||
| 115 | test_builder => $test, | ||||||||||||||||||||||||||||||||||||||||||
| 116 | vars => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 117 | diag_body_text_on_failure => 1 }; | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 3 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | # Takes an accessor name as its only argument. Returns a boolean | ||||||||||||||||||||||||||||||||||||||||||
| 125 | # indicating whether the accessor takes a locator argument. | ||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | sub _has_no_locator | ||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_has_no_locator: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | my ($accessor) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | return exists NO_LOCATOR->{$accessor}; | |||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | # Takes an L<XML::LibXML::Node> and returns the 'literal' content. At | ||||||||||||||||||||||||||||||||||||||||||
| 135 | # the moment, that involves joining all the text parts together and | ||||||||||||||||||||||||||||||||||||||||||
| 136 | # converting C<br> elements into newlines. | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | sub _node_literal | ||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_node_literal: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | my $node = shift; | |||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | my $literal = ''; | |||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | foreach my $child ($node->childNodes()) { | |||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | my $type = $child->nodeType; | |||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | # Does the node require special processing? | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | if ( $child->nodeType == XML_ELEMENT_NODE | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$child->nodeType == 1 and $child->nodeName =~ /^br$/i
MC/DC0%0/2
$child->nodeType == 1 and $child->nodeName =~ /^br$/i
$child->nodeType == 1
$child->nodeName =~ /^br$/i
Truth table0%0/3
A and B
A= $child->nodeType == 1B= $child->nodeName =~ /^br$/i
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | and $child->nodeName =~ /^br$/i) { | ||||||||||||||||||||||||||||||||||||||||||
| 149 | # BR elements need to be converted to newlines. | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | $literal .= "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 152 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 153 | # If it's not a 'special' node, just grab the text. | ||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | $literal .= $child->textContent(); | |||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | return $literal; | |||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | # Takes the document element of an L<XML::LibXML::Document> as its | ||||||||||||||||||||||||||||||||||||||||||
| 162 | # single argument. Extracts and returns the Selenium test specifications | ||||||||||||||||||||||||||||||||||||||||||
| 163 | # from that XML as a list of arrayrefs. Each arrayref comprises the test | ||||||||||||||||||||||||||||||||||||||||||
| 164 | # command (e.g. C<storeAttribute>), the two arguments for the command | ||||||||||||||||||||||||||||||||||||||||||
| 165 | # and the line number where the test specification begins in the XML. If | ||||||||||||||||||||||||||||||||||||||||||
| 166 | # the command takes fewer than two arguments, the unused parts of the | ||||||||||||||||||||||||||||||||||||||||||
| 167 | # arrayref will contain empty strings. | ||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | sub _xml_to_testdata | ||||||||||||||||||||||||||||||||||||||||||
| 170 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_xml_to_testdata: called CC=3 SCAR=11.9
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 2 | my ($doc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | 2 | my $xmlns = $doc->getAttribute('xmlns'); | |||||||||||||||||||||||||||||||||||||||||
| 174 | 2 | ▶ | if (not $xmlns) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 1 | die "Test document must have an xmlns attribute."; | |||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||
| 177 | 1 | my $xpc = XML::LibXML::XPathContext->new($doc); | |||||||||||||||||||||||||||||||||||||||||
| 178 | 1 | $xpc->registerNs('x', $xmlns); | |||||||||||||||||||||||||||||||||||||||||
| 179 | 1 | my $trs = $xpc->findnodes('//x:tbody//x:tr'); | |||||||||||||||||||||||||||||||||||||||||
| 180 | 1 | my $trsc = $trs->size(); | |||||||||||||||||||||||||||||||||||||||||
| 181 | 1 | ▶ | if (not $trsc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | 1 | die "Test document contains no tests."; | |||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | my @data = | ||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | map { [ (map { _node_literal($_) } | |||||||||||||||||||||||||||||||||||||||||
| 187 | ($_->nonBlankChildNodes())), | ||||||||||||||||||||||||||||||||||||||||||
| 188 | $_->line_number() ] } | ||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | @{$trs}; | |||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | return @data; | |||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | # Takes a string as its only argument. Converts it from 'camel-case' to | ||||||||||||||||||||||||||||||||||||||||||
| 195 | # 'perl-case' and returns it. For example, if passed the string | ||||||||||||||||||||||||||||||||||||||||||
| 196 | # C<verifyElementHeight>, this will return C<verify_element_height>. | ||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | sub _perl_case | ||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_perl_case: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | my ($str) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | $str =~ s/([a-z])([A-Z])/$1_\L$2/g; | |||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | $str = lcfirst $str; | |||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | return $str; | |||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | # Takes the variable hashref and a variable name as its arguments. If | ||||||||||||||||||||||||||||||||||||||||||
| 209 | # the name designates an array variable, returns the contents of that | ||||||||||||||||||||||||||||||||||||||||||
| 210 | # array as a single string, joined with commas. Otherwise, returns the | ||||||||||||||||||||||||||||||||||||||||||
| 211 | # scalar value of the variable. | ||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | sub _var_to_string | ||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_var_to_string: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | my ($vars, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | return | ||||||||||||||||||||||||||||||||||||||||||
| 218 | (ref $vars->{$name} eq 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ? join ',', @{$vars->{$name}} | |||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | : $vars->{$name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | # Takes the variable hashref and a string as its arguments. If the | ||||||||||||||||||||||||||||||||||||||||||
| 224 | # string contains variable placeholders, these are replaced with the | ||||||||||||||||||||||||||||||||||||||||||
| 225 | # corresponding values from the variable hashref. Returns the string | ||||||||||||||||||||||||||||||||||||||||||
| 226 | # after substitution has occurred. | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | sub _substitute_vars | ||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_substitute_vars: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | my ($vars, $str) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | my @varnames = | ||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | grep { exists $vars->{$_} } | |||||||||||||||||||||||||||||||||||||||||
| 234 | ($str =~ /\${(.*?)}/g); | ||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | for my $varname (@varnames) { | |||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | my $value = _var_to_string($vars, $varname); | |||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | $str =~ s/\${$varname}/$value/g; | |||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | if ($str =~ /^javascript{.*}/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | my @varnames = | ||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | grep { exists $vars->{$_} } | |||||||||||||||||||||||||||||||||||||||||
| 244 | ($str =~ /storedVars\[['"](.*?)['"]\]/); | ||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | for my $varname (@varnames) { | |||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | my $value = '"'.(_var_to_string($vars, $varname)).'"'; | |||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | $str =~ s/storedVars\[['"]$varname['"]\]/$value/g; | |||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | return $str; | |||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | # Takes the L<Test::WWW::Selenium> object as its only argument. Returns | ||||||||||||||||||||||||||||||||||||||||||
| 256 | # the timeout that should be used for operations that involve waiting. | ||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | sub _get_timeout_in_seconds | ||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_timeout_in_seconds: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | my ($sel) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | # There's no other way to get the timeout from the | ||||||||||||||||||||||||||||||||||||||||||
| 263 | # Test::WWW::Selenium object, unfortunately. | ||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | return | ||||||||||||||||||||||||||||||||||||||||||
| 266 | (defined $sel->{_timeout}) | ||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | ? int ($sel->{_timeout} / 1000) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 268 | : 30; | ||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | # Takes a pattern as its only argument. Returns a Regexp object for | ||||||||||||||||||||||||||||||||||||||||||
| 272 | # testing values against this pattern. | ||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | sub _get_regexp_from_pattern | ||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_regexp_from_pattern: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | my ($pattern) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | if ($pattern =~ s/^regexp://) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | return qr/$pattern/; | |||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | if ($pattern =~ s/^exact://) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | return qr/\Q$pattern\E/; | |||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | for ($pattern) { | |||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | s/^glob://; | |||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | s/\*/\.\*/g; | |||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | s/\?/\./g; | |||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | return qr/$pattern/; | |||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | # Takes a pattern and a boolean describing the 'sense' of the test | ||||||||||||||||||||||||||||||||||||||||||
| 293 | # command as its arguments (the boolean argument should be true for a | ||||||||||||||||||||||||||||||||||||||||||
| 294 | # test like C<assertElementPresent>, and false for a test like | ||||||||||||||||||||||||||||||||||||||||||
| 295 | # C<assertElementNotPresent>). Returns a verb that can be used in a test | ||||||||||||||||||||||||||||||||||||||||||
| 296 | # case string to describe the type of match that is occurring. | ||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | sub _get_match_str_from_pattern | ||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_match_str_from_pattern: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | my ($pattern, $success) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | return | ||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | ($pattern =~ /^exact:/) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | ? ($success) | ||||||||||||||||||||||||||||||||||||||||||
| 305 | ? 'equals' | ||||||||||||||||||||||||||||||||||||||||||
| 306 | : 'does not equal' | ||||||||||||||||||||||||||||||||||||||||||
| 307 | : ($success) | ||||||||||||||||||||||||||||||||||||||||||
| 308 | ? 'matches' | ||||||||||||||||||||||||||||||||||||||||||
| 309 | : 'does not match'; | ||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | # Takes a command name (any string), a target, a value, a boolean | ||||||||||||||||||||||||||||||||||||||||||
| 313 | # describing whether the command has no locator argument, a boolean | ||||||||||||||||||||||||||||||||||||||||||
| 314 | # describing whether the test command is a boolean accessor and a | ||||||||||||||||||||||||||||||||||||||||||
| 315 | # boolean describing the 'sense' of the test command (see | ||||||||||||||||||||||||||||||||||||||||||
| 316 | # L<_get_match_str_from_pattern>). Returns a string that can be used as | ||||||||||||||||||||||||||||||||||||||||||
| 317 | # the description of the test case. | ||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | sub _get_test_case_str | ||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_test_case_str: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | my ($pcommand, $target, $value, $has_no_locator, $is_bool, $success) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | my $str = "$pcommand " .(($has_no_locator) ? '' : "'$target'"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | ▶ | if ($is_bool) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | return $str; | |||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | $value = ($has_no_locator ? $target : $value); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | my $match_str = _get_match_str_from_pattern($value, $success); | |||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | return "$str $match_str '$value'"; | |||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | # Takes an accessor type (the prefix of the accessor, e.g. C<store>), an | ||||||||||||||||||||||||||||||||||||||||||
| 336 | # accessor name (including the type), a target (first test argument), a | ||||||||||||||||||||||||||||||||||||||||||
| 337 | # value (second test argument), the filename of the Selenium HTML test | ||||||||||||||||||||||||||||||||||||||||||
| 338 | # file, the line number of the test, a L<Test::WWW::Selenium> object, a | ||||||||||||||||||||||||||||||||||||||||||
| 339 | # L<Test::Builder> object and a variable hashref as its arguments. Runs | ||||||||||||||||||||||||||||||||||||||||||
| 340 | # the accessor test using the L<Test::Builder> and returns a boolean | ||||||||||||||||||||||||||||||||||||||||||
| 341 | # describing whether the test succeeded. Updates the variable hashref if | ||||||||||||||||||||||||||||||||||||||||||
| 342 | # necessary, as well. | ||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||
| 344 | sub _handle_accessor | ||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_handle_accessor: not called CC=20 SCAR=60.4
| |||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | my ($type, $command, $target, $value, $slnm_file, $line_number, | |||||||||||||||||||||||||||||||||||||||||
| 347 | $sel, $tb, $vars, $diag) = @_; | ||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | my ($part) = ($command =~ /^$type(.*)/); | |||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | my ($part_minus_not) = ($part =~ /Not([A-Z].*)/); | |||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | if (not exists STORES->{$part} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
exists {"Alert" => 1,"AlertNotPresent" => 1,"AlertPresent" => 1,"AllButtons" => 1,"AllFields" => 1,"AllLinks" => 1,"AllWindowIds" => 1,"AllWindowNames" => 1,"AllWindowTitles" => 1,"Attribute" => 1,"AttributeFromAllWindows" => 1,"BodyText" => 1,"Checked" => 1,"Confirmation" => 1,"ConfirmationNotPresent" => 1,"ConfirmationPresent" => 1,"Cookie" => 1,"CursorPosition" => 1,"Editable" => 1,"ElementHeight" => 1,"ElementIndex" => 1,"ElementNotPresent" => 1,"ElementPositionLeft" => 1,"ElementPositionTop" => 1,"ElementPresent" => 1,"ElementWidth" => 1,"Eval" => 1,"Expression" => 1,"HtmlSource" => 1,"Location" => 1,"LogMessages" => 1,"NotChecked" => 1,"NotEditable" => 1,"NotOrdered" => 1,"NotSomethingSelected" => 1,"NotVisible" => 1,"Ordered" => 1,"Prompt" => 1,"PromptNotPresent" => 1,"PromptPresent" => 1,"SelectOptions" => 1,"SelectedId" => 1,"SelectedIds" => 1,"SelectedIndex" => 1,"SelectedIndexes" => 1,"SelectedLabel" => 1,"SelectedLabels" => 1,"SelectedValue" => 1,"SelectedValues" => 1,"SomethingSelected" => 1,"Table" => 1,"Text" => 1,"TextNotPresent" => 1,"TextPresent" => 1,"Title" => 1,"Value" => 1,"Visible" => 1,"WhetherThisFrameMatchFrameExpression" => 1}->{$part} or defined $part_minus_not and exists {"Alert" => 1,"AlertNotPresent" => 1,"AlertPresent" => 1,"AllButtons" => 1,"AllFields" => 1,"AllLinks" => 1,"AllWindowIds" => 1,"AllWindowNames" => 1,"AllWindowTitles" => 1,"Attribute" => 1,"AttributeFromAllWindows" => 1,"BodyText" => 1,"Checked" => 1,"Confirmation" => 1,"ConfirmationNotPresent" => 1,"ConfirmationPresent" => 1,"Cookie" => 1,"CursorPosition" => 1,"Editable" => 1,"ElementHeight" => 1,"ElementIndex" => 1,"ElementNotPresent" => 1,"ElementPositionLeft" => 1,"ElementPositionTop" => 1,"ElementPresent" => 1,"ElementWidth" => 1,"Eval" => 1,"Expression" => 1,"HtmlSource" => 1,"Location" => 1,"LogMessages" => 1,"NotChecked" => 1,"NotEditable" => 1,"NotOrdered" => 1,"NotSomethingSelected" => 1,"NotVisible" => 1,"Ordered" => 1,"Prompt" => 1,"PromptNotPresent" => 1,"PromptPresent" => 1,"SelectOptions" => 1,"SelectedId" => 1,"SelectedIds" => 1,"SelectedIndex" => 1,"SelectedIndexes" => 1,"SelectedLabel" => 1,"SelectedLabels" => 1,"SelectedValue" => 1,"SelectedValues" => 1,"SomethingSelected" => 1,"Table" => 1,"Text" => 1,"TextNotPresent" => 1,"TextPresent" => 1,"Title" => 1,"Value" => 1,"Visible" => 1,"WhetherThisFrameMatchFrameExpression" => 1}->{$part_minus_not}
defined $part_minus_not and exists {"Alert" => 1,"AlertNotPresent" => 1,"AlertPresent" => 1,"AllButtons" => 1,"AllFields" => 1,"AllLinks" => 1,"AllWindowIds" => 1,"AllWindowNames" => 1,"AllWindowTitles" => 1,"Attribute" => 1,"AttributeFromAllWindows" => 1,"BodyText" => 1,"Checked" => 1,"Confirmation" => 1,"ConfirmationNotPresent" => 1,"ConfirmationPresent" => 1,"Cookie" => 1,"CursorPosition" => 1,"Editable" => 1,"ElementHeight" => 1,"ElementIndex" => 1,"ElementNotPresent" => 1,"ElementPositionLeft" => 1,"ElementPositionTop" => 1,"ElementPresent" => 1,"ElementWidth" => 1,"Eval" => 1,"Expression" => 1,"HtmlSource" => 1,"Location" => 1,"LogMessages" => 1,"NotChecked" => 1,"NotEditable" => 1,"NotOrdered" => 1,"NotSomethingSelected" => 1,"NotVisible" => 1,"Ordered" => 1,"Prompt" => 1,"PromptNotPresent" => 1,"PromptPresent" => 1,"SelectOptions" => 1,"SelectedId" => 1,"SelectedIds" => 1,"SelectedIndex" => 1,"SelectedIndexes" => 1,"SelectedLabel" => 1,"SelectedLabels" => 1,"SelectedValue" => 1,"SelectedValues" => 1,"SomethingSelected" => 1,"Table" => 1,"Text" => 1,"TextNotPresent" => 1,"TextPresent" => 1,"Title" => 1,"Value" => 1,"Visible" => 1,"WhetherThisFrameMatchFrameExpression" => 1}->{$part_minus_not}
MC/DC0%0/3
exists {"Alert" => 1,"AlertNotPresent" => 1,"AlertPresent" => 1,"AllButtons" => 1,"AllFields" => 1,"AllLinks" => 1,"AllWindowIds" => 1,"AllWindowNames" => 1,"AllWindowTitles" => 1,"Attribute" => 1,"AttributeFromAllWindows" => 1,"BodyText" => 1,"Checked" => 1,"Confirmation" => 1,"ConfirmationNotPresent" => 1,"ConfirmationPresent" => 1,"Cookie" => 1,"CursorPosition" => 1,"Editable" => 1,"ElementHeight" => 1,"ElementIndex" => 1,"ElementNotPresent" => 1,"ElementPositionLeft" => 1,"ElementPositionTop" => 1,"ElementPresent" => 1,"ElementWidth" => 1,"Eval" => 1,"Expression" => 1,"HtmlSource" => 1,"Location" => 1,"LogMessages" => 1,"NotChecked" => 1,"NotEditable" => 1,"NotOrdered" => 1,"NotSomethingSelected" => 1,"NotVisible" => 1,"Ordered" => 1,"Prompt" => 1,"PromptNotPresent" => 1,"PromptPresent" => 1,"SelectOptions" => 1,"SelectedId" => 1,"SelectedIds" => 1,"SelectedIndex" => 1,"SelectedIndexes" => 1,"SelectedLabel" => 1,"SelectedLabels" => 1,"SelectedValue" => 1,"SelectedValues" => 1,"SomethingSelected" => 1,"Table" => 1,"Text" => 1,"TextNotPresent" => 1,"TextPresent" => 1,"Title" => 1,"Value" => 1,"Visible" => 1,"WhetherThisFrameMatchFrameExpression" => 1}->{$part} or defined $part_minus_not and exists {"Alert" => 1,"AlertNotPresent" => 1,"AlertPresent" => 1,"AllButtons" => 1,"AllFields" => 1,"AllLinks" => 1,"AllWindowIds" => 1,"AllWindowNames" => 1,"AllWindowTitles" => 1,"Attribute" => 1,"AttributeFromAllWindows" => 1,"BodyText" => 1,"Checked" => 1,"Confirmation" => 1,"ConfirmationNotPresent" => 1,"ConfirmationPresent" => 1,"Cookie" => 1,"CursorPosition" => 1,"Editable" => 1,"ElementHeight" => 1,"ElementIndex" => 1,"ElementNotPresent" => 1,"ElementPositionLeft" => 1,"ElementPositionTop" => 1,"ElementPresent" => 1,"ElementWidth" => 1,"Eval" => 1,"Expression" => 1,"HtmlSource" => 1,"Location" => 1,"LogMessages" => 1,"NotChecked" => 1,"NotEditable" => 1,"NotOrdered" => 1,"NotSomethingSelected" => 1,"NotVisible" => 1,"Ordered" => 1,"Prompt" => 1,"PromptNotPresent" => 1,"PromptPresent" => 1,"SelectOptions" => 1,"SelectedId" => 1,"SelectedIds" => 1,"SelectedIndex" => 1,"SelectedIndexes" => 1,"SelectedLabel" => 1,"SelectedLabels" => 1,"SelectedValue" => 1,"SelectedValues" => 1,"SomethingSelected" => 1,"Table" => 1,"Text" => 1,"TextNotPresent" => 1,"TextPresent" => 1,"Title" => 1,"Value" => 1,"Visible" => 1,"WhetherThisFrameMatchFrameExpression" => 1}->{$part_minus_not}
exists {"Alert" => 1,"AlertNotPresent" => 1,"AlertPresent" => 1,"AllButtons" => 1,"AllFields" => 1,"AllLinks" => 1,"AllWindowIds" => 1,"AllWindowNames" => 1,"AllWindowTitles" => 1,"Attribute" => 1,"AttributeFromAllWindows" => 1,"BodyText" => 1,"Checked" => 1,"Confirmation" => 1,"ConfirmationNotPresent" => 1,"ConfirmationPresent" => 1,"Cookie" => 1,"CursorPosition" => 1,"Editable" => 1,"ElementHeight" => 1,"ElementIndex" => 1,"ElementNotPresent" => 1,"ElementPositionLeft" => 1,"ElementPositionTop" => 1,"ElementPresent" => 1,"ElementWidth" => 1,"Eval" => 1,"Expression" => 1,"HtmlSource" => 1,"Location" => 1,"LogMessages" => 1,"NotChecked" => 1,"NotEditable" => 1,"NotOrdered" => 1,"NotSomethingSelected" => 1,"NotVisible" => 1,"Ordered" => 1,"Prompt" => 1,"PromptNotPresent" => 1,"PromptPresent" => 1,"SelectOptions" => 1,"SelectedId" => 1,"SelectedIds" => 1,"SelectedIndex" => 1,"SelectedIndexes" => 1,"SelectedLabel" => 1,"SelectedLabels" => 1,"SelectedValue" => 1,"SelectedValues" => 1,"SomethingSelected" => 1,"Table" => 1,"Text" => 1,"TextNotPresent" => 1,"TextPresent" => 1,"Title" => 1,"Value" => 1,"Visible" => 1,"WhetherThisFrameMatchFrameExpression" => 1}->{$part}
defined $part_minus_not
exists {"Alert" => 1,"AlertNotPresent" => 1,"AlertPresent" => 1,"AllButtons" => 1,"AllFields" => 1,"AllLinks" => 1,"AllWindowIds" => 1,"AllWindowNames" => 1,"AllWindowTitles" => 1,"Attribute" => 1,"AttributeFromAllWindows" => 1,"BodyText" => 1,"Checked" => 1,"Confirmation" => 1,"ConfirmationNotPresent" => 1,"ConfirmationPresent" => 1,"Cookie" => 1,"CursorPosition" => 1,"Editable" => 1,"ElementHeight" => 1,"ElementIndex" => 1,"ElementNotPresent" => 1,"ElementPositionLeft" => 1,"ElementPositionTop" => 1,"ElementPresent" => 1,"ElementWidth" => 1,"Eval" => 1,"Expression" => 1,"HtmlSource" => 1,"Location" => 1,"LogMessages" => 1,"NotChecked" => 1,"NotEditable" => 1,"NotOrdered" => 1,"NotSomethingSelected" => 1,"NotVisible" => 1,"Ordered" => 1,"Prompt" => 1,"PromptNotPresent" => 1,"PromptPresent" => 1,"SelectOptions" => 1,"SelectedId" => 1,"SelectedIds" => 1,"SelectedIndex" => 1,"SelectedIndexes" => 1,"SelectedLabel" => 1,"SelectedLabels" => 1,"SelectedValue" => 1,"SelectedValues" => 1,"SomethingSelected" => 1,"Table" => 1,"Text" => 1,"TextNotPresent" => 1,"TextPresent" => 1,"Title" => 1,"Value" => 1,"Visible" => 1,"WhetherThisFrameMatchFrameExpression" => 1}->{$part_minus_not}
Truth table0%0/4
A or B and C
A= exists {"Alert" => 1,"AlertNotPresent" => 1,"AlertPresent" => 1,"AllButtons" => 1,"AllFields" => 1,"AllLinks" => 1,"AllWindowIds" => 1,"AllWindowNames" => 1,"AllWindowTitles" => 1,"Attribute" => 1,"AttributeFromAllWindows" => 1,"BodyText" => 1,"Checked" => 1,"Confirmation" => 1,"ConfirmationNotPresent" => 1,"ConfirmationPresent" => 1,"Cookie" => 1,"CursorPosition" => 1,"Editable" => 1,"ElementHeight" => 1,"ElementIndex" => 1,"ElementNotPresent" => 1,"ElementPositionLeft" => 1,"ElementPositionTop" => 1,"ElementPresent" => 1,"ElementWidth" => 1,"Eval" => 1,"Expression" => 1,"HtmlSource" => 1,"Location" => 1,"LogMessages" => 1,"NotChecked" => 1,"NotEditable" => 1,"NotOrdered" => 1,"NotSomethingSelected" => 1,"NotVisible" => 1,"Ordered" => 1,"Prompt" => 1,"PromptNotPresent" => 1,"PromptPresent" => 1,"SelectOptions" => 1,"SelectedId" => 1,"SelectedIds" => 1,"SelectedIndex" => 1,"SelectedIndexes" => 1,"SelectedLabel" => 1,"SelectedLabels" => 1,"SelectedValue" => 1,"SelectedValues" => 1,"SomethingSelected" => 1,"Table" => 1,"Text" => 1,"TextNotPresent" => 1,"TextPresent" => 1,"Title" => 1,"Value" => 1,"Visible" => 1,"WhetherThisFrameMatchFrameExpression" => 1}->{$part}B= defined $part_minus_notC= exists {"Alert" => 1,"AlertNotPresent" => 1,"AlertPresent" => 1,"AllButtons" => 1,"AllFields" => 1,"AllLinks" => 1,"AllWindowIds" => 1,"AllWindowNames" => 1,"AllWindowTitles" => 1,"Attribute" => 1,"AttributeFromAllWindows" => 1,"BodyText" => 1,"Checked" => 1,"Confirmation" => 1,"ConfirmationNotPresent" => 1,"ConfirmationPresent" => 1,"Cookie" => 1,"CursorPosition" => 1,"Editable" => 1,"ElementHeight" => 1,"ElementIndex" => 1,"ElementNotPresent" => 1,"ElementPositionLeft" => 1,"ElementPositionTop" => 1,"ElementPresent" => 1,"ElementWidth" => 1,"Eval" => 1,"Expression" => 1,"HtmlSource" => 1,"Location" => 1,"LogMessages" => 1,"NotChecked" => 1,"NotEditable" => 1,"NotOrdered" => 1,"NotSomethingSelected" => 1,"NotVisible" => 1,"Ordered" => 1,"Prompt" => 1,"PromptNotPresent" => 1,"PromptPresent" => 1,"SelectOptions" => 1,"SelectedId" => 1,"SelectedIds" => 1,"SelectedIndex" => 1,"SelectedIndexes" => 1,"SelectedLabel" => 1,"SelectedLabels" => 1,"SelectedValue" => 1,"SelectedValues" => 1,"SomethingSelected" => 1,"Table" => 1,"Text" => 1,"TextNotPresent" => 1,"TextPresent" => 1,"Title" => 1,"Value" => 1,"Visible" => 1,"WhetherThisFrameMatchFrameExpression" => 1}->{$part_minus_not}
| |||||||||||||||||||||||||||||||||||||||||||
| 353 | and (not defined $part_minus_not | ||||||||||||||||||||||||||||||||||||||||||
| 354 | or not exists STORES->{$part_minus_not})) { | ||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | die "Invalid accessor '$part' at line $line_number."; | |||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | my $is_bool = exists BOOL_VALUE_STORES->{$part}; | |||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | my $is_array = exists ARRAY_VALUE_STORES->{$part}; | |||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | my $not = $part =~ s/Not([A-Z])/$1/; | |||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | my $has_no_locator = _has_no_locator($part); | |||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | my $pcmd = _perl_case($part); | |||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | my $get_pcmd = 'get_'.$pcmd; | |||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | my $is_pcmd = 'is_'.$pcmd; | |||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | my $pcommand = _perl_case($command); | |||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | $value = ($has_no_locator ? $target : $value); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | ▶ | my @get_args = ($has_no_locator ? () : $target); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | my $regexp = _get_regexp_from_pattern($value); | |||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | my (undef, $test_file, $test_line_number) = $tb->caller(1); | |||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | my $test_case_str = | |||||||||||||||||||||||||||||||||||||||||
| 375 | _get_test_case_str($pcommand, $target, $value, | ||||||||||||||||||||||||||||||||||||||||||
| 376 | $has_no_locator, $is_bool, not $not). | ||||||||||||||||||||||||||||||||||||||||||
| 377 | " ($slnm_file:$line_number; ". | ||||||||||||||||||||||||||||||||||||||||||
| 378 | "$test_file:$test_line_number)"; | ||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | if ($type eq 'waitFor') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | my $timeout = _get_timeout_in_seconds($sel); | |||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | my $test_coderef = | ||||||||||||||||||||||||||||||||||||||||||
| 384 | ($is_bool) | ||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | ? sub { my $res = $sel->$is_pcmd($target); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | ▶ | ($not) ? not $res : $res } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | ▶ | : sub { my $new_value = $sel->$get_pcmd(@get_args); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | my $res = ($new_value =~ $regexp); | |||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | ▶ | ($not) ? not $res : $res }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | WAIT: { | ||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | for (1..$timeout + 1) { | |||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | if (eval { $test_coderef->() }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | pass($test_case_str); | |||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | last WAIT; | |||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | sleep(1); | |||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | $tb->ok(0, "$test_case_str ". | |||||||||||||||||||||||||||||||||||||||||
| 400 | "(timed out, see line $line_number)"); | ||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | ▶ | if ($diag) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | my $html = "Response HTML source:\n".$sel->get_html_source(); | |||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | $tb->diag($html); | |||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | ▶ | my @check_values = | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 411 | ($is_bool) | ||||||||||||||||||||||||||||||||||||||||||
| 412 | ? $sel->$is_pcmd($target) | ||||||||||||||||||||||||||||||||||||||||||
| 413 | : $sel->$get_pcmd(@get_args); | ||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | my $check_value = join ',', @check_values; | |||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | ▶ | if ($type eq 'store') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | ▶ | $vars->{$value} = | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 419 | ($is_array) | ||||||||||||||||||||||||||||||||||||||||||
| 420 | ? \@check_values | ||||||||||||||||||||||||||||||||||||||||||
| 421 | : $check_value; | ||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | my $res; | |||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | ▶ | if ($is_bool) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | ▶ | $res = | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 428 | ($not) | ||||||||||||||||||||||||||||||||||||||||||
| 429 | ? $tb->ok((not $check_value), $test_case_str) | ||||||||||||||||||||||||||||||||||||||||||
| 430 | : $tb->ok(($check_value), $test_case_str); | ||||||||||||||||||||||||||||||||||||||||||
| 431 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | $res = | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 433 | ($not) | ||||||||||||||||||||||||||||||||||||||||||
| 434 | ? $tb->unlike($check_value, $regexp, $test_case_str) | ||||||||||||||||||||||||||||||||||||||||||
| 435 | : $tb->like( $check_value, $regexp, $test_case_str); | ||||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | ▶ | if (not $res) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | ▶ | if ($diag) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | my $html = "Response HTML source:\n".$sel->get_html_source(); | |||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | $tb->diag($html); | |||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | ▶ | if ($type eq 'assert') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||
| 450 | # Takes a L<Test::WWW::Selenium> object, a L<Test::Builder> object, a | ||||||||||||||||||||||||||||||||||||||||||
| 451 | # hashref of variables, the filename of the Selenium HTML test file and | ||||||||||||||||||||||||||||||||||||||||||
| 452 | # a test specification (as per L<_xml_to_testdata>) as its arguments. | ||||||||||||||||||||||||||||||||||||||||||
| 453 | # Runs the test and returns a boolean indicating whether the test was | ||||||||||||||||||||||||||||||||||||||||||
| 454 | # successful. | ||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||
| 456 | sub _run_test | ||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_run_test: not called CC=17 SCAR=57.2
| |||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | my ($sel, $tb, $vars, $slnm_file, $test, $diag) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | my ($command, $target, $value, $line_number) = @{$test}; | |||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | $target = _substitute_vars($vars, $target); | |||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | $value = _substitute_vars($vars, $value); | |||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | my @accessor_args = ($command, $target, $value, | |||||||||||||||||||||||||||||||||||||||||
| 466 | $slnm_file, $line_number, | ||||||||||||||||||||||||||||||||||||||||||
| 467 | $sel, $tb, $vars, $diag); | ||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | my (undef, $test_file, $test_line_number) = $tb->caller(); | |||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | ▶ | if ($command eq 'store') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | my $script; | |||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | ▶ | $vars->{$value} = | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 474 | (($script) = ($target =~ /^javascript{(.*)}$/)) | ||||||||||||||||||||||||||||||||||||||||||
| 475 | ? $sel->get_eval($script) | ||||||||||||||||||||||||||||||||||||||||||
| 476 | : $target; | ||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | ▶ | if ($command eq 'echo') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | print $target."\n"; | |||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | ▶ | if ($command eq 'waitForCondition') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | my ($script, $timeout) = ($target, $value); | |||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | if (not $timeout) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | $timeout = _get_timeout_in_seconds($sel) * 1000; | |||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | my $test_str = "waitForCondition($target, $value) ". | |||||||||||||||||||||||||||||||||||||||||
| 489 | "($slnm_file:$line_number; ". | ||||||||||||||||||||||||||||||||||||||||||
| 490 | "$test_file:$test_line_number)"; | ||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | my $res = eval { $sel->wait_for_condition($script, $timeout) }; | |||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | my $error = $@; | |||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | $tb->ok($res, $test_str); | |||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | ▶ | if ($error) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | $tb->diag($error); | |||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | return $res; | |||||||||||||||||||||||||||||||||||||||||
| 498 | } | ||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | if ($command eq 'waitForPageToLoad') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | my $timeout = $target; | |||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | ▶ | if (not $timeout) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | $timeout = _get_timeout_in_seconds($sel) * 1000; | |||||||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | my $test_str = "waitForPageToLoad($target, $value) ". | |||||||||||||||||||||||||||||||||||||||||
| 505 | "($slnm_file:$line_number; ". | ||||||||||||||||||||||||||||||||||||||||||
| 506 | "$test_file:$test_line_number)"; | ||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | my $res = eval { $sel->wait_for_page_to_load($timeout) }; | |||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | my $error = $@; | |||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | $tb->ok($res, $test_str); | |||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | ▶ | if ($error) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | $tb->diag($error); | |||||||||||||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | return $res; | |||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | ▶ | if (my ($type) = ($command =~ /(^assert|^verify|^waitFor|^store)/)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | return _handle_accessor($type, @accessor_args); | |||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||
| 519 | # Convert the command to 'perl-case' and append '_ok' (this will | ||||||||||||||||||||||||||||||||||||||||||
| 520 | # be the corresponding method name, assuming that it exists). If | ||||||||||||||||||||||||||||||||||||||||||
| 521 | # the command ends in 'AndWait', call C<wait_for_page_to_load> | ||||||||||||||||||||||||||||||||||||||||||
| 522 | # afterwards. Note that C<can> cannot be used, because | ||||||||||||||||||||||||||||||||||||||||||
| 523 | # L<Test::WWW::Selenium> uses autoload. | ||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | my $pcmd = _perl_case($command); | |||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | my $wait = ($pcmd =~ s/_and_wait$//); | |||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | $pcmd .= '_ok'; | |||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | my $res = eval { | |||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | my (@args) = grep { defined $_ } ($target, $value); | |||||||||||||||||||||||||||||||||||||||||
| 531 | # Including the command in the test description means that | ||||||||||||||||||||||||||||||||||||||||||
| 532 | # information is repeated for successful cases, but is | ||||||||||||||||||||||||||||||||||||||||||
| 533 | # necessary because the command is not included in the failure | ||||||||||||||||||||||||||||||||||||||||||
| 534 | # message (if the test fails). | ||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | my $test_desc = "$command(".(join ', ', @args).") ". | |||||||||||||||||||||||||||||||||||||||||
| 536 | "($slnm_file:$line_number; ". | ||||||||||||||||||||||||||||||||||||||||||
| 537 | "$test_file:$test_line_number)"; | ||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | my $res = $sel->$pcmd(@args, $test_desc); | |||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | ▶ | if ($res and $wait) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$res and $wait
MC/DC0%0/2
$res and $wait
$res
$wait
Truth table0%0/3
A and B
A= $resB= $wait
| |||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | my $timeout = _get_timeout_in_seconds($sel) * 1000; | |||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | $sel->wait_for_page_to_load($timeout); | |||||||||||||||||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | $res; | |||||||||||||||||||||||||||||||||||||||||
| 544 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | ▶ | if (my $error = $@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 546 | my $str = | ||||||||||||||||||||||||||||||||||||||||||
| 547 | join ', ', | ||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | map { "'$_'" } | |||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | grep { $_ } | |||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | (@{$test})[0..2]; | |||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | ▶ | my $die_msg = | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 552 | ($error =~ /Undefined subroutine|Can't locate.*method/) | ||||||||||||||||||||||||||||||||||||||||||
| 553 | ? "Unhandled command at $slnm_file:$line_number: [$str]" | ||||||||||||||||||||||||||||||||||||||||||
| 554 | : "Died while running test: $error: [$str]"; | ||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | die $die_msg; | |||||||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | ▶ | if (not $res) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | ▶ | if ($diag) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | my $html = "Response HTML source:\n".$sel->get_html_source(); | |||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | $tb->diag($html); | |||||||||||||||||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||
| 568 | sub run | ||||||||||||||||||||||||||||||||||||||||||
| 569 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=11 SCAR=33.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 570 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||
| 572 | 3 | my %args = validate(@_, | |||||||||||||||||||||||||||||||||||||||||
| 573 | { data => { type => SCALAR, optional => 1 }, | ||||||||||||||||||||||||||||||||||||||||||
| 574 | path => { type => SCALAR, optional => 1 }, } | ||||||||||||||||||||||||||||||||||||||||||
| 575 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||
| 577 | 3 | ▶ | if (not $args{'data'} and not $args{'path'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$args{"data"} or $args{"path"}
MC/DC100%2/2
$args{"data"} or $args{"path"}
$args{"data"}
$args{"path"}
Truth table100%3/3
A or B
A= $args{"data"}B= $args{"path"}
| |||||||||||||||||||||||||||||||||||||||||||
| 578 | 1 | die "Either 'data' or 'path' must be provided."; | |||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||
| 580 | 2 | ▶ | if ($args{'data'} and $args{'path'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$args{"data"} and $args{"path"}
MC/DC50%1/2
$args{"data"} and $args{"path"}
$args{"data"}
$args{"path"}
Truth table66%2/3
A and B
A= $args{"data"}B= $args{"path"}
| |||||||||||||||||||||||||||||||||||||||||||
| 581 | 1 | die "One (and only one) of 'data' and 'path' must be provided."; | |||||||||||||||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||
| 584 | 1 | my $parser = XML::LibXML->new(); | |||||||||||||||||||||||||||||||||||||||||
| 585 | 1 | $parser->load_ext_dtd(0); | |||||||||||||||||||||||||||||||||||||||||
| 586 | 1 | $parser->line_numbers(1); | |||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||
| 588 | 1 | ▶ | if ($args{'path'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 589 | open my $fh, '<', $args{'path'} | ||||||||||||||||||||||||||||||||||||||||||
| 590 | 1 | ▶ | or die "Unable to open ".$args{'path'}.": $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | $args{'data'} = do { local $/; <$fh> }; | |||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | ▶ | my $filename = $args{'path'} ? $args{'path'} : '[no filename]'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | my $doc = $parser->parse_string($args{'data'}); | |||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | my @testdata = _xml_to_testdata($doc->getDocumentElement()); | |||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | my $sel = $self->{'selenium'}; | |||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | ▶ | if (not $self->{'opened'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | $self->{'opened'} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | $sel->open('/'); | |||||||||||||||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | for my $test (@testdata) { | |||||||||||||||||||||||||||||||||||||||||
| 607 | my $res = _run_test($sel, $self->{'test_builder'}, | ||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | $self->{'vars'}, $filename, $test, | |||||||||||||||||||||||||||||||||||||||||
| 609 | $self->diag_body_text_on_failure()); | ||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | ▶ | if (not $res) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 612 | } | ||||||||||||||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||
| 618 | sub vars | ||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vars: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | return $self->{'vars'}; | |||||||||||||||||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||
| 625 | sub diag_body_text_on_failure | ||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diag_body_text_on_failure: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | my ($self, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | my $current_value = $self->{'diag_body_text_on_failure'}; | |||||||||||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | ▶ | if (@_ == 2) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | $self->{'diag_body_text_on_failure'} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 633 | } | ||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | return $current_value; | |||||||||||||||||||||||||||||||||||||||||
| 636 | } | ||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||
| 638 | 10 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||
| 640 | __END__ | ||||||||||||||||||||||||||||||||||||||||||