|
@@ -21,6 +21,7 @@ use File::Spec();
|
|
|
use Sub::Install();
|
|
use Sub::Install();
|
|
|
use Net::EmptyPort();
|
|
use Net::EmptyPort();
|
|
|
use Capture::Tiny qw{capture_merged};
|
|
use Capture::Tiny qw{capture_merged};
|
|
|
|
|
+use Unicode::Normalize qw{NFC};
|
|
|
|
|
|
|
|
use Selenium::Specification;
|
|
use Selenium::Specification;
|
|
|
|
|
|
|
@@ -79,6 +80,12 @@ Only turn this off when you are debugging.
|
|
|
|
|
|
|
|
Default: true
|
|
Default: true
|
|
|
|
|
|
|
|
|
|
+=item C<normalize> BOOLEAN - Automatically normalize UTF-8 output using Normal Form C (NFC).
|
|
|
|
|
+
|
|
|
|
|
+If another normal form is preferred, you should turn this off and directly use L<Unicode::Normalize>.
|
|
|
|
|
+
|
|
|
|
|
+Default: true
|
|
|
|
|
+
|
|
|
=item C<post_callbacks> ARRAY[CODE] - Executed after each request to the selenium server.
|
|
=item C<post_callbacks> ARRAY[CODE] - Executed after each request to the selenium server.
|
|
|
|
|
|
|
|
Callbacks are passed $self, an HTTP::Tiny response hashref and the request hashref.
|
|
Callbacks are passed $self, an HTTP::Tiny response hashref and the request hashref.
|
|
@@ -144,6 +151,7 @@ sub new($class,%options) {
|
|
|
$options{auto_close} //= 1;
|
|
$options{auto_close} //= 1;
|
|
|
$options{browser} //= '';
|
|
$options{browser} //= '';
|
|
|
$options{headless} //= 1;
|
|
$options{headless} //= 1;
|
|
|
|
|
+ $options{normalize} //= 1;
|
|
|
|
|
|
|
|
#create client_dir and log-dir
|
|
#create client_dir and log-dir
|
|
|
my $dir = File::Spec->catdir( $options{client_dir},"perl-client" );
|
|
my $dir = File::Spec->catdir( $options{client_dir},"perl-client" );
|
|
@@ -457,7 +465,10 @@ sub _request($self, $method, %params) {
|
|
|
|
|
|
|
|
print "$res->{status} : $res->{content}\n" if $self->{debug} && ref $res eq 'HASH';
|
|
print "$res->{status} : $res->{content}\n" if $self->{debug} && ref $res eq 'HASH';
|
|
|
|
|
|
|
|
- my $decoded_content = eval { JSON::MaybeXS::decode_json($res->{content}) };
|
|
|
|
|
|
|
+ # all the selenium servers are UTF-8
|
|
|
|
|
+ my $normal = $res->{content};
|
|
|
|
|
+ $normal = NFC( $normal ) if $self->{normalize};
|
|
|
|
|
+ my $decoded_content = eval { JSON::MaybeXS->new()->utf8()->decode( $normal ) };
|
|
|
confess "$res->{reason} :\n Consult $subject->{href}\nRaw Error:\n$res->{content}\n" unless $res->{success};
|
|
confess "$res->{reason} :\n Consult $subject->{href}\nRaw Error:\n$res->{content}\n" unless $res->{success};
|
|
|
|
|
|
|
|
if (grep { $method eq $_ } @no_process) {
|
|
if (grep { $method eq $_ } @no_process) {
|
|
@@ -648,6 +659,12 @@ Don't close this or your test will fail for obvious reasons.
|
|
|
This also means that if you have to send ^C (SIGTERM) to your script or exit() prematurely, said window may be left dangling,
|
|
This also means that if you have to send ^C (SIGTERM) to your script or exit() prematurely, said window may be left dangling,
|
|
|
as these behave a lot more like POSIX::_exit() does on unix systems.
|
|
as these behave a lot more like POSIX::_exit() does on unix systems.
|
|
|
|
|
|
|
|
|
|
+=head1 UTF-8 considerations
|
|
|
|
|
+
|
|
|
|
|
+The JSON responses from the selenium server are decoded as UTF-8, as per the Selenium standard.
|
|
|
|
|
+As a convenience, we automatically apply NFC to output via L<Unicode::Normalize>, which can be disabled by passing normalize=0 to the constructor.
|
|
|
|
|
+If you are comparing output from selenium calls against UTF-8 glyphs, `use utf8`, `use feature qw{unicode_strings}` and normalization is strongly suggested.
|
|
|
|
|
+
|
|
|
=head1 AUTHOR
|
|
=head1 AUTHOR
|
|
|
|
|
|
|
|
George S. Baugh <george@troglodyne.net>
|
|
George S. Baugh <george@troglodyne.net>
|