Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 274 lines (193 sloc) 5.944 kb
84ac344 Attempt at a non-xslt transform of iedoc.xml using perl.
lukec authored
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4 use Test::More qw/no_plan/;
75244c1 create_www_selenium.pl now works to convert iedoc.xml into Selenium.pm
lukec authored
5 use Test::Differences;
84ac344 Attempt at a non-xslt transform of iedoc.xml using perl.
lukec authored
6 use lib 'util';
75244c1 create_www_selenium.pl now works to convert iedoc.xml into Selenium.pm
lukec authored
7
8 BEGIN: {
9 use_ok 'WWW::Selenium::XMLParseUtils',
10 qw/extract_functions html2pod strip_blockquotes/;
11 }
84ac344 Attempt at a non-xslt transform of iedoc.xml using perl.
lukec authored
12
13 Single_line: {
14 my $xml = '<blockquote>Monkey</blockquote>';
15 my $pod = <<EOT;
16
17 =over
18
19 Monkey
20
21 =back
22
23 EOT
24 is strip_blockquotes($xml), $pod;
25 }
26
27 Split_single_line: {
28 my $xml = <<EOT;
29 <blockquote>
30 Matches elements based on their values. This is particularly useful for refining a list of similarly-named toggle-buttons.</blockquote>
31 EOT
32 my $pod = <<EOT;
33
34 =over
35
36 Matches elements based on their values. This is particularly useful for refining a list of similarly-named toggle-buttons.
37
38 =back
39
40 EOT
41 is strip_blockquotes($xml), $pod;
42 }
43
44 Split_single_line: {
45 my $xml = <<EOT;
46 <blockquote>
47 Thing one
48 Thing two
49 </blockquote>
50 EOT
51 my $pod = <<EOT;
52
53 =over
54
55 Thing one
56 Thing two
57
58 =back
59
60 EOT
61 is strip_blockquotes($xml), $pod;
62 }
63
64 Nested_blocks: {
65 my $xml = <<EOT;
66 <blockquote>
67 Thing one
68 <blockquote>
69 Thing two
70 </blockquote>
71 Thing three
72 </blockquote>
73 EOT
74 my $pod = <<EOT;
75
76 =over
77
78 Thing one
79
80 =over
81
82 Thing two
83
84 =back
85
86
87 Thing three
88
89 =back
90
91 EOT
92 is strip_blockquotes($xml), $pod;
93 }
75244c1 create_www_selenium.pl now works to convert iedoc.xml into Selenium.pm
lukec authored
94
95 Extract_functions: {
96 my $xml = <<'EOT';
97 <function name="click">
98
99 <param name="locator">an element locator</param>
100
101 <comment>Clicks on a link, button, checkbox or radio button. If the click action
102 causes a new page to load (like a link usually does), call
103 waitForPageToLoad.</comment>
104
105 </function>
106 <function name="doubleClick">
107
108 <param name="locator">an element locator</param>
109
110 <comment>Double clicks on a link, button, checkbox or radio button. If the double click action
111 causes a new page to load (like a link usually does), call
112 waitForPageToLoad.</comment>
113
114 </function>
115 EOT
116 my @functions;
117 push @functions, <<'EOT';
118 =item $sel-E<gt>click($locator)
119
120 Clicks on a link, button, checkbox or radio button. If the click action
121 causes a new page to load (like a link usually does), call
122 waitForPageToLoad.
123
124 =over
125
126 $locator is an element locator
127
128 =back
129
130 =cut
131
132 sub click {
133 my $self = shift;
134 $self->do_command("click", @_);
135 }
136
137 EOT
138 push @functions, <<'EOT';
139 =item $sel-E<gt>double_click($locator)
140
141 Double clicks on a link, button, checkbox or radio button. If the double click action
142 causes a new page to load (like a link usually does), call
143 waitForPageToLoad.
144
145 =over
146
147 $locator is an element locator
148
149 =back
150
151 =cut
152
153 sub double_click {
154 my $self = shift;
155 $self->do_command("doubleClick", @_);
156 }
157
158 EOT
159
160 my @got = extract_functions($xml);
161 is scalar(@got), scalar(@functions);
162 for my $i (0 .. @got-1) {
3a5605f Update unit tests for parsing iedoc.xml
lukec authored
163 eq_or_diff $got[$i]->{text}, $functions[$i];
75244c1 create_www_selenium.pl now works to convert iedoc.xml into Selenium.pm
lukec authored
164 }
165 }
166
167 Extract_functions_two_params: {
168 my $xml = <<'EOT';
169 <function name="clickAt">
170
171 <param name="locator">an element locator</param>
172
173 <param name="coordString">specifies the x,y position (i.e. - 10,20) of the mouse event relative to the element returned by the locator.</param>
174
175 <comment>Clicks on a link, button, checkbox or radio button. If the click action
176 causes a new page to load (like a link usually does), call
177 waitForPageToLoad.
178
179 Beware of http://jira.openqa.org/browse/SEL-280, which will lead some event handlers to
180 get null event arguments. Read the bug for more details, including a workaround.</comment>
181
182 </function>
183 EOT
184 my @functions;
185 push @functions, <<'EOT';
186 =item $sel-E<gt>click_at($locator, $coord_string)
187
188 Clicks on a link, button, checkbox or radio button. If the click action
189 causes a new page to load (like a link usually does), call
190 waitForPageToLoad.
191
192 Beware of http://jira.openqa.org/browse/SEL-280, which will lead some event handlers to
193 get null event arguments. Read the bug for more details, including a workaround.
194
195 =over
196
197 $locator is an element locator
198
199 $coord_string is specifies the x,y position (i.e. - 10,20) of the mouse event relative to the element returned by the locator.
200
201 =back
202
203 =cut
204
205 sub click_at {
206 my $self = shift;
207 $self->do_command("clickAt", @_);
208 }
209
210 EOT
211
212 my @got = extract_functions($xml);
213 is scalar(@got), scalar(@functions);
214 for my $i (0 .. @got-1) {
3a5605f Update unit tests for parsing iedoc.xml
lukec authored
215 eq_or_diff $got[$i]->{text}, $functions[$i];
75244c1 create_www_selenium.pl now works to convert iedoc.xml into Selenium.pm
lukec authored
216 }
217 }
218
219 Function_with_return_type: {
220 my $xml = <<'EOT';
221 <function name="getLogMessages">
222
223 <return type="string">all log messages seen since the last call to this API</return>
224
225 <comment>Return the contents of the log.
226
227 <p>This is a placeholder intended to make the code generator make this API
228 available to clients. The selenium server will intercept this call, however,
229 and return its recordkeeping of log messages since the last call to this API.
230 Thus this code in JavaScript will never be called.</p>
231
232 <p>The reason I opted for a servercentric solution is to be able to support
233 multiple frames served from different domains, which would break a
234 centralized JavaScript logging mechanism under some conditions.</p></comment>
235
236 </function>
237 EOT
238 my @functions;
239 push @functions, <<'EOT';
240 =item $sel-E<gt>get_log_messages()
241
242 Return the contents of the log.
243
244 This is a placeholder intended to make the code generator make this API
245 available to clients. The selenium server will intercept this call, however,
246 and return its recordkeeping of log messages since the last call to this API.
247 Thus this code in JavaScript will never be called.
248
249 The reason I opted for a servercentric solution is to be able to support
250 multiple frames served from different domains, which would break a
251 centralized JavaScript logging mechanism under some conditions.
252
253 =over
254
255 Returns all log messages seen since the last call to this API
256
257 =back
258
259 =cut
260
261 sub get_log_messages {
262 my $self = shift;
263 return $self->get_string("getLogMessages", @_);
264 }
265
266 EOT
267
268 my @got = extract_functions($xml);
269 is scalar(@got), scalar(@functions);
270 for my $i (0 .. @got-1) {
3a5605f Update unit tests for parsing iedoc.xml
lukec authored
271 eq_or_diff $got[$i]->{text}, $functions[$i];
75244c1 create_www_selenium.pl now works to convert iedoc.xml into Selenium.pm
lukec authored
272 }
273 }
Something went wrong with that request. Please try again.