From 8f66c23ec677916d5eff2b6a68165567bcef5f89 Mon Sep 17 00:00:00 2001 From: Andrew Grangaard Date: Thu, 25 Oct 2018 15:08:26 -0700 Subject: [PATCH] Duplicate simple test using the Appium.pm module --- .../examples/perl/ios_simple_appium.pl | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 sample-code/examples/perl/ios_simple_appium.pl diff --git a/sample-code/examples/perl/ios_simple_appium.pl b/sample-code/examples/perl/ios_simple_appium.pl new file mode 100644 index 00000000..95f922be --- /dev/null +++ b/sample-code/examples/perl/ios_simple_appium.pl @@ -0,0 +1,49 @@ +#! /usr/bin/perl + +use strict; +use warnings; +use Test::More; +use File::Spec; +use Appium; + +# Helper to build absolute path relative to location of this file. +sub path_from_rel { + my $rel = shift; + + my ($vol, $dir, $file) = File::Spec->splitpath( File::Spec->rel2abs( __FILE__ )); + File::Spec->catpath($vol, $dir, $rel) +} + +my $caps = { + app => path_from_rel('/../../apps/TestApp/build/release-iphonesimulator/TestApp.app'), + browserName => "", + deviceName => "iPhone 6", + platformName => "iOS", + platformVersion => "8.1" +}; + +my $driver = Appium->new( + remote_server_addr => "127.0.0.1", + port => 4723, + desired_capabilities => $caps +); + +ok(defined $driver, 'Instantiated an iOS driver!'); + +my $expected_sum; +foreach (qw/1 2/) { + my $text_field = $driver->find_element('TextField' . $_, 'name'); + my $rand = int(rand(20)); + $expected_sum += $rand; + $text_field->send_keys($rand); +} + +my $compute_button = $driver->find_element('ComputeSumButton', 'name'); +$compute_button->click; + +my $sum_element = $driver->find_element($expected_sum, 'name'); +ok($sum_element->get_text eq $expected_sum, 'We can do addition!'); + +$driver->quit; + +done_testing;