Test/Selenium/Remote/WebElement.pm

filter: Statementstmt 100% 23 / 23 Branchbran 100% 2 / 2 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 2 totaltotal 94.4% 34 / 36 SCAR 13.9
CC
4
Cov
100%
BUILD
3.0
has_args
2.0
BEGIN
1.0
CRAP 4.0
« Selenium/Remote/ErrorHandler.pm ↑ Summary Selenium/Remote/Mock/Commands.pm »
1 package Test::Selenium::Remote::WebElement;
2 14 $Test::Selenium::Remote::WebElement::VERSION = '1.49';
3 # ABSTRACT: A sub-class of L<Selenium::Remote::WebElement>, with several test-specific method additions.
4  
5 14 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 14 ▶use Sub::Install;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 14 extends 'Selenium::Remote::WebElement';
8  
9 =for Pod::Coverage *EVERYTHING*
10  
11 =cut
12  
13 # list of test functions to be built
14  
15 has func_list => (
16 is => 'lazy',
17 builder => sub {
18 return [
19 2 ▶ 'clear_ok', 'click_ok', 'send_keys_ok',
Subroutine _build_func_list: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
20 'is_displayed_ok', 'is_enabled_ok', 'is_selected_ok',
21 'submit_ok', 'text_is', 'text_isnt',
22 'text_like', 'text_unlike', 'attribute_is',
23 'attribute_isnt', 'attribute_like', 'attribute_unlike',
24 'value_is', 'value_isnt', 'value_like',
25 'value_unlike', 'tag_name_is', 'tag_name_isnt',
26 'tag_name_like', 'tag_name_unlike'
27 ];
28 }
29 14 );
30  
31 14 with 'Test::Selenium::Remote::Role::DoesTesting';
32  
33 # helper so we could specify the num of args a method takes (if any)
34  
35 sub has_args {
36 32 ▶ my $self = shift;
Subroutine has_args: called CC=2 SCAR=6.9
Pod undocumented
37 32 my $fun_name = shift;
38 32 my $hash_fun_args = {
39 'get_attribute' => 1,
40 'send_keys' => 1,
41 };
42 32 ▶ return ( $hash_fun_args->{$fun_name} // 0 );
Condition100%2/2
$hash_fun_args->{$fun_name} // 0
l!l
725
MC/DC100%1/1
$hash_fun_args->{$fun_name} // 0
$hash_fun_args->{$fun_name}
Truth table100%2/2
A
A= $hash_fun_args->{$fun_name}
Aresult
11
00
43 }
44  
45 # install the test methods into the class namespace
46  
47 sub BUILD {
48 33 ▶ my $self = shift;
Subroutine BUILD: called CC=3 SCAR=11.0
Pod undocumented
49 33 foreach my $method_name ( @{ $self->func_list } ) {
50 759 ▶ unless ( defined( __PACKAGE__->can($method_name) ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined __PACKAGE__->can($method_name)) 69 690 759
51 69 my $sub = $self->_build_sub($method_name);
52 69 Sub::Install::install_sub(
53 {
54 code => $sub,
55 into => __PACKAGE__,
56 as => $method_name
57 }
58 );
59 }
60 }
61 }
62  
63 14 1;
64  
65 __END__
66  
67 =head1 DESCRIPTION
68  
69 This is an I<experimental> addition to the Selenium::Remote::Driver
70 distribution, and some interfaces may change.
71  
72 =head1 METHODS
73  
74 All methods from L<Selenium::Remote::WebElement> are available through this
75 module, as well as the following test-specific methods. All test names are optional.
76  
77 text_is($match_str,$test_name);
78 text_isnt($match_str,$test_name);
79 text_like($match_re,$test_name);
80 text_unlike($match_re,$test_name);
81  
82 tag_name_is($match_str,$test_name);
83 tag_name_isnt($match_str,$test_name);
84 tag_name_like($match_re,$test_name);
85 tag_name_unlike($match_re,$test_name);
86  
87 value_is($match_str,$test_name);
88 value_isnt($match_str,$test_name);
89 value_like($match_re,$test_name);
90 value_unlike($match_re,$test_name);
91  
92 clear_ok($test_name);
93 click_ok($test_name);
94 submit_ok($test_name);
95 is_selected_ok($test_name);
96 is_enabled_ok($test_name);
97 is_displayed_ok($test_name);
98  
99 send_keys_ok($str)
100 send_keys_ok($str,$test_name)
101  
102 attribute_is($attr_name,$match_str,$test_name);
103 attribute_isnt($attr_name,$match_str,$test_name);
104 attribute_like($attr_name,$match_re,$test_name);
105 attribute_unlike($attr_name,$match_re,$test_name);
106  
107 css_attribute_is($attr_name,$match_str,$test_name); # TODO
108 css_attribute_isnt($attr_name,$match_str,$test_name); # TODO
109 css_attribute_like($attr_name,$match_re,$test_name); # TODO
110 css_attribute_unlike($attr_name,$match_re,$test_name); # TODO
111  
112 element_location_is([x,y]) # TODO
113 element_location_in_view_is([x,y]) # TODO
114  
115 =head1 AUTHORS
116  
117 =over 4
118  
119 =item *
120  
121 Created by: Mark Stosberg <mark@stosberg.org>, but inspired by
122 L<Test::WWW::Selenium> and its authors.
123  
124 =back
125  
126 =head1 COPYRIGHT AND LICENSE
127  
128 Copyright (c) 2013 Mark Stosberg
129  
130 This program is free software; you can redistribute it and/or
131 modify it under the same terms as Perl itself.
« Selenium/Remote/ErrorHandler.pm ↑ Summary Selenium/Remote/Mock/Commands.pm »