Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Selenium.pm #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update Selenium.pm
Fixed bug in get_string_array where instead of correctly returning an empty array when there are no results it returns an array containing a single empty string. The new code uses a negative lookbehind assertion to split on unescaped commas. It then uses a map to remove the escape characters from the list of strings.
  • Loading branch information
James-Switzer committed Oct 14, 2013
commit 76a0ef552f448919b2ed31e61b97a44f6a2688ea
16 changes: 1 addition & 15 deletions lib/WWW/Selenium.pm
Original file line number Diff line number Diff line change
Expand Up @@ -522,21 +522,7 @@ sub get_string_array {
my $result = $self->get_string(@_);
my $token = "";
my @tokens = ();
my @chars = split(//, $result);
for (my $i = 0; $i < @chars; $i++) {
my $char = $chars[$i];
if ($char eq '\\') {
$i++;
$char = $chars[$i];
$token .= $char;
} elsif ($char eq ',') {
push (@tokens, $token);
$token = "";
} else {
$token .= $char;
}
}
push (@tokens, $token);
@tokens = map {s/\\(.)/\1/g; $_} split /(?<!\\),/, $result;
return @tokens;
}

Expand Down