line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
=head1 NAME |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
Weasel::FindExpanders::Dojo - XPath mnemonic hooks for Dojo 1.x widgets |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 VERSION |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
0.02 |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use Weasel::FindExpanders::Dojo; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $button = $session->find($session->page, "@button|{text=>\"whatever\"}"); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
package Weasel::FindExpanders::Dojo; |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
|
1001
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
144
|
|
21
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
1
|
|
619
|
use Weasel::FindExpanders qw/ register_find_expander /; |
|
1
|
|
|
|
|
491
|
|
|
1
|
|
|
|
|
1117
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 DESCRIPTION |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=over |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=item button_expander |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Finds button tags or input tags of types submit, reset, button and image. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Criteria: |
34
|
|
|
|
|
|
|
* 'id' |
35
|
|
|
|
|
|
|
* 'name' |
36
|
|
|
|
|
|
|
* 'text' matches content between open and close tag |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub button_expander { |
41
|
0
|
|
|
0
|
1
|
|
my %args = @_; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
my @clauses; |
44
|
0
|
0
|
|
|
|
|
if (defined $args{text}) { |
45
|
0
|
|
|
|
|
|
push @clauses, "text()='$args{text}'"; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
for my $clause (qw/ id name /) { |
49
|
0
|
0
|
|
|
|
|
if (defined $args{$clause}) { |
50
|
0
|
|
|
|
|
|
push @clauses, "\@$clause='$args{$clause}'"; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
0
|
0
|
|
|
|
|
my $clause = |
55
|
|
|
|
|
|
|
(@clauses) ? ('and .//*[' . join(' and ', @clauses) . ']'): ''; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# dijitButtonNode has a click handler |
58
|
|
|
|
|
|
|
# (its parent is has the dijitButton class, but only has a submit handler) |
59
|
0
|
|
|
|
|
|
return ".//*[contains(concat(' ',normalize-space(\@class),' '), |
60
|
|
|
|
|
|
|
' dijitButtonNode ') $clause]" |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=item option_expander |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Finds options for dijit.form.Select, after the drop down has been invoked |
68
|
|
|
|
|
|
|
at least once (the options don't exist in the DOM tree before that point). |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Because of that, it's best to search the options through the C<select> tag, |
71
|
|
|
|
|
|
|
which offers a C<find_option> method which specifically compensates for the |
72
|
|
|
|
|
|
|
issue. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Additionally, it's impossible to search options by the value being submitted; |
75
|
|
|
|
|
|
|
these don't exist in the DOM tree unlike with the C<option> tags of |
76
|
|
|
|
|
|
|
C<select>s. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Criteria: |
79
|
|
|
|
|
|
|
* 'id' |
80
|
|
|
|
|
|
|
* 'text' matches the visible description of the item |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub option_expander { |
85
|
0
|
|
|
0
|
1
|
|
my %args = @_; |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
my @clauses; |
88
|
0
|
0
|
|
|
|
|
if (defined $args{text}) { |
89
|
0
|
|
|
|
|
|
push @clauses, "text()='$args{text}'"; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
for my $clause (qw/ id /) { |
93
|
0
|
0
|
|
|
|
|
if (defined $args{$clause}) { |
94
|
0
|
|
|
|
|
|
push @clauses, "\@$clause='$args{$clause}'"; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
0
|
0
|
|
|
|
|
my $clause = |
99
|
|
|
|
|
|
|
(@clauses) ? ('and .//*[' . join(' and ', @clauses) . ']'): ''; |
100
|
0
|
|
|
|
|
|
return ".//*[\@role='option' $clause]"; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=back |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=cut |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
register_find_expander($_->{name}, 'Dojo', $_->{expander}) |
111
|
|
|
|
|
|
|
for ({ name => 'button', expander => \&button_expander }, |
112
|
|
|
|
|
|
|
{ name => 'option', expander => \&option_expander }, |
113
|
|
|
|
|
|
|
); |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; |