| 1 | #!/usr/bin/perl | ||||||||||||||||||||||||||||
| 2 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 3 | my $title; | |||||||||||||||||||||||||||
| 6 | my @rows; | ||||||||||||||||||||||||||||
| 7 | 3 | ▶ | while (<>) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 8 | 27 | ▶ | if (m#<title>([^<]+)</title>#) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 9 | 2 | $title = $1; | |||||||||||||||||||||||||||
| 10 | 2 | next; | |||||||||||||||||||||||||||
| 11 | } | ||||||||||||||||||||||||||||
| 12 | 25 | ▶ | if (m#^<tr>#) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 13 | 8 | push @rows, grep {defined} parse_row(); | |||||||||||||||||||||||||||
| 14 | 8 | next; | |||||||||||||||||||||||||||
| 15 | } | ||||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 3 | ▶ | unless ($title and @rows) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$title and @rows
MC/DC50%1/2
$title and @rows
$title
@rows
Truth table66%2/3
A and B
A= $titleB= @rows
| |||||||||||||||||||||||||||||
| 19 | 1 | print STDERR <<EOUSAGE; | |||||||||||||||||||||||||||
| 20 | USAGE: $0 [source html] | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | $0 will read the given file, or STDIN for selenium HTML, | ||||||||||||||||||||||||||||
| 23 | as generated by Selenium Recorder. | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | The output will be selenium wiki syntax, compatible with | ||||||||||||||||||||||||||||
| 26 | selenium-regen. | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | Example: | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | $0 foo.html > foo.wiki | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | EOUSAGE | ||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 3 | print "| $title |\n"; | |||||||||||||||||||||||||||
| 36 | 3 | foreach my $r (@rows) { | |||||||||||||||||||||||||||
| 37 | 8 | print "| ", join(' | ', @$r), " |\n"; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 8 | ▶ | sub parse_row { | ||||||||||||||||||||||||||
|
Subroutine
parse_row: called CC=7 SCAR=20.2
| |||||||||||||||||||||||||||||
| 41 | 8 | my ($cmd, @opts); | |||||||||||||||||||||||||||
| 42 | 8 | my $row = ''; | |||||||||||||||||||||||||||
| 43 | 8 | ▶ | while (<>) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 36 | $row .= $_; | |||||||||||||||||||||||||||
| 45 | 36 | ▶ | last if m#^</tr>#; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | 28 | ▶ | if (m#\s*<td>([^<]+)</td>#) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | 18 | ▶ | if (defined $cmd) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | 10 | push @opts, $1; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | else { | ||||||||||||||||||||||||||||
| 51 | 8 | $cmd = $1; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | 18 | next; | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | 8 | ▶ | unless (defined $cmd and @opts) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $cmd and @opts
MC/DC0%0/2
defined $cmd and @opts
defined $cmd
@opts
Truth table33%1/3
A and B
A= defined $cmdB= @opts
| |||||||||||||||||||||||||||||
| 57 | 0 | warn "Could not parse row: $row\n"; | |||||||||||||||||||||||||||
| 58 | 0 | return; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | 8 | return [ $cmd, @opts ]; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||