Appium
view release on metacpan or search on metacpan
0.05 2014-11-13
- Restore restrictions about caps vs desired; this is just 0.03 again.
0.04 2014-11-12
- Loosen restrictions about caps vs desired_capabilities in
constructor
0.03 2014-11-11
- Use hard dependency on S-R-D v0.22 to allow us to use our own
Finders constant and ErrorHandler class.
- Add a slew of appium endpoints: notifs, network connections, lock,
shake, app management, file/folder managing, set_text, and others.
0.02 2014-08-08
- Add context management endpoints
- Use snake case for internal endpoints: hide_keyboard replaces
hideKeyboard
0.01 2014-08-07
- Initial release: only additional Appium-specific sub is
hide_keyboard
lib/Appium.pm view on Meta::CPAN
$appium->page;
$appium->find_element('TextField1', 'name')->send_keys('5');
$appium->quit;
=head1 DESCRIPTION
Appium is an open source test automation framework for use with native
and hybrid mobile apps. It drives iOS and Android apps using the
WebDriver JSON wire protocol. This module is a thin extension of
L<Selenium::Remote::Driver> that adds Appium specific API endpoints
and Appium-specific constructor defaults. It's woefully incomplete at
the moment, so feel free to pitch in at the L<Github
repo|https://github.com/appium/perl-client>! For details on how Appium
extends the Webdriver spec, see the Selenium project's L<spec-draft
document|https://code.google.com/p/selenium/source/browse/spec-draft.md?repo=mobile>.
Note that like L<Selenium::Remote::Driver>, you shouldn't have to
instantiate L<Appium::Element> on your own; this module will create
them when necessary so that all you need to know is what methods are
appropriate on an element vs the driver.
lib/Appium/Commands.pm view on Meta::CPAN
Appium::Commands - Appium specific extensions to the Webdriver JSON protocol
=head1 VERSION
version 0.0804
=head1 DESCRIPTION
There's not much to see here. View the source if you'd like to see the
Appium specific endpoints. Otherwise, you might be looking for
L<Appium> or L<Selenium::Remote::Commands>.
=head1 SEE ALSO
Please see those modules/websites for more information related to this module.
=over 4
=item *
use Test::More;
use Test::Exception;
use Cwd qw/abs_path/;
use Appium::Commands;
BEGIN: {
my $test_lib = abs_path(__FILE__);
$test_lib =~ s/(.*)\/.*\.t$/$1\/lib/;
push @INC, $test_lib;
require MockAppium;
MockAppium->import(qw/endpoint_ok alias_ok/);
unless (use_ok('Appium')) {
BAIL_OUT("Couldn't load Appium");
exit;
}
}
my $mock_appium = MockAppium->new;
INVALID_STRATEGY: {
if ($expected->{test} eq 'can pass a strategy') {
ok( exists $params->{key}, 'hide_keyboard, key: strategy and key are included');
cmp_ok( $params->{key}, 'eq', 'Done', 'hide_keyboard, val: strategy and key are included');
}
}
}
ANDROID_KEYCODES: {
my $code = 176;
endpoint_ok('press_keycode', [ $code ], { keycode => $code });
endpoint_ok('long_press_keycode', [ $code, 'metastate' ], { keycode => $code, metastate => 'metastate' });
}
PUSH_PULL: {
my $path = '/fake/path';
my $data = 'pretend to be base 64 encoded';
endpoint_ok('pull_file', [ $path ], { path => $path });
endpoint_ok('pull_folder', [ $path ], { path => $path });
endpoint_ok('push_file', [ $path, $data ], { path => $path, data => $data });
}
FIND: {
my @selector = qw/fake selection critera/;
endpoint_ok('complex_find', [ @selector ], { selector => \@selector });
}
APP: {
endpoint_ok('background_app', [ 5 ], { seconds => 5 });
endpoint_ok('is_app_installed', [ 'a fake bundle id' ], { bundleId => 'a fake bundle id' });
endpoint_ok('install_app', [ '/fake/path/to.app' ], { appPath => '/fake/path/to.app' });
endpoint_ok('remove_app', [ '/fake/path/to.app' ], { appId => '/fake/path/to.app' });
endpoint_ok('launch_app');
endpoint_ok('close_app');
}
DEVICE: {
endpoint_ok('lock', [ 5 ], { seconds => 5 });
endpoint_ok('is_locked');
endpoint_ok('shake');
endpoint_ok('open_notifications');
endpoint_ok('network_connection');
endpoint_ok('set_network_connection', [ 6 ], { parameters => { type => 6 } });
}
MISC: {
endpoint_ok('end_test_coverage', [ 'intent', 'path' ], {
intent => 'intent',
path => 'path'
});
ok($mock_appium->can('tap'), 'tap: Appium can tap');
lives_ok(sub { $mock_appium->tap }, 'tap: and we can tap without dying');
}
done_testing;
t/lib/MockAppium.pm view on Meta::CPAN
use strict;
use warnings;
use JSON;
use Appium;
use Test::More;
use Test::Deep;
use Test::LWP::UserAgent;
use Test::MockObject::Extends;
our @ISA = qw/Exporter/;
our @EXPORT_OK = qw/endpoint_ok alias_ok/;
my $mock_appium;
my @aliases = keys %{ Appium::Commands->new->get_cmds };
sub new {
my ($self, %args) = @_;
my $tua = Test::LWP::UserAgent->new;
my $fake_session_response = {
cmd_return => {},
cmd_status => 'OK',
t/lib/MockAppium.pm view on Meta::CPAN
my $appium = Appium->new($init_args);
$mock_appium = Test::MockObject::Extends->new($appium);
$mock_appium->mock('_execute_command', sub { shift; wantarray ? @_ : \@_;});
return $mock_appium;
}
sub endpoint_ok {
my ($endpoint, $args, $expected) = @_;
my ($res, $params) = $mock_appium->$endpoint(@{ $args });
# check it's in the commands hash
alias_ok($endpoint, $res);
# validate the args get processed as expected
cmp_deeply($params, $expected, $endpoint . ': params are properly organized');
}
sub alias_ok {
my ($endpoint, $res) = @_;
my @alias_found = grep { $_ eq $res->{command} } @aliases;
return ok(@alias_found, $endpoint . ': has a valid endpoint alias');
}
1;
( run in 0.613 second using v1.01-cache-2.11-cpan-b61123c0432 )