forked from appium/appium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request appium#2663 from gempesaw/perl-examples
Interested in adding perl code samples ?
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#! /usr/bin/perl | ||
|
||
use strict; | ||
use warnings; | ||
use Test::More; | ||
use Cwd qw/getcwd abs_path/; | ||
use Selenium::Remote::Driver 0.20; | ||
|
||
my $app = getcwd() . '/../../apps/TestApp/build/Release-iphonesimulator/TestApp.app'; | ||
my $caps = { | ||
app => abs_path($app), | ||
browserName => "", | ||
deviceName => "iPhone Simulator", | ||
platformName => "iOS", | ||
platformVersion => "7.1" | ||
}; | ||
|
||
my $driver = Selenium::Remote::Driver->new_from_caps( | ||
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; |