Skip to content

Commit

Permalink
First crack at #2, looks like I need to implement JSONWire support :(
Browse files Browse the repository at this point in the history
  • Loading branch information
teodesian committed Feb 25, 2021
1 parent 0e0c707 commit d9cc8c5
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
25 changes: 25 additions & 0 deletions at/sanity.test
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,31 @@ $extra = '/' if grep { $^O eq $_ } qw{msys MSWin32};
my $sut = 'file://' . $extra . abs_path("$FindBin::Bin/test.html");
my $sut2 = 'file://' . $extra . abs_path("$FindBin::Bin/other.html");

#Do WinAppDriver testing if we are on windows and have it installed at all

my $winapp = eval { Selenium::Client->new( driver => 'WinApp', debug => $ENV{DEBUG} ) };
if ($winapp) {
my $caps = {
app => 'C:\\Windows\\System32\\notepad.exe',
platformName => "WINDOWS",
platform => "WINDOWS",
deviceName => "WindowsPC",
appArguments => "zippy.txt",
appWorkingDir => '.',
"ms:experimental-webdriver" => JSON::true,
};

#XXX the WC3 support is only "sorta" in that they don't support modern caps
my @ret = $winapp->NewSession( desiredCapabilities => $caps );
use Data::Dumper;
print Dumper(\@ret);
my $notepad;
my $input = $notepad->FindElement( using => 'css selector', value => 'Edit' );
$input->ElementSendKeys( text => 'tickle');
is($input->GetElementProperty( name => 'value' ), 'tickle', "Can clear and send keys to a text input");
}
die;

my @browsers = qw{firefox chrome};
push(@browsers, 'MicrosoftEdge') if grep { $^O eq $_ } qw{MSWin32 msys};
push(@browsers, 'safari') if $^O eq 'darwin';
Expand Down
55 changes: 55 additions & 0 deletions lib/Selenium/Driver/WinApp.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package Selenium::Driver::WinApp;

use strict;
use warnings;

no warnings 'experimental';
use feature qw/signatures/;

use Carp qw{confess};
use File::Which;

#ABSTRACT: Tell Selenium::Client how to spawn the Windows Application Driver

=head1 Mode of Operation
Spawns a WinAppDriver server on the provided port (which the caller will assign randomly)
Relies on WinAppDriver being in your $PATH (put in this to your user's PATH env var:)
%PROGRAMFILES(X86)%\Windows Application Driver
Pipes log output to ~/.selenium/perl-client/$port.log
=head1 SUBROUTINES
=head2 build_spawn_opts($class,$object)
Builds a command string which can run the driver binary.
All driver classes must build this.
=cut

sub _driver {
return 'WinAppDriver.exe';
}

sub build_spawn_opts($class,$object) {
$object->{driver_class} = $class;
$object->{driver_version} //= '';
$object->{log_file} //= "$object->{client_dir}/perl-client/selenium-$object->{port}.log";
$object->{driver_file} = File::Which::which($class->_driver());
die "Could not find driver!" unless $object->{driver_file};
#XXX appears that escaping from system() does not work correctly on win32 thanks to the join() I have? to do later, sigh
$object->{driver_file} = qq/"$object->{driver_file}"/;

my @config = ($object->{port});

# Build command string
$object->{command} //= [
$object->{driver_file},
@config,
];
return $object;
}

1;

0 comments on commit d9cc8c5

Please sign in to comment.