-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy path50-tick.t
88 lines (71 loc) · 3.52 KB
/
50-tick.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!perl -w
use strict;
use Test::More;
use Cwd;
use URI::file;
use File::Basename;
use File::Spec;
use Data::Dumper;
use Log::Log4perl qw(:easy);
use WWW::Mechanize::Chrome;
use lib '.';
use t::helper;
Log::Log4perl->easy_init($ERROR); # Set priority of root logger to ERROR
# What instances of Chrome will we try?
my @instances = t::helper::browser_instances();
my $testcount = 18;
if (my $err = t::helper::default_unavailable) {
plan skip_all => "Couldn't connect to Chrome: $@";
exit
} else {
plan tests => $testcount*@instances;
};
sub new_mech {
t::helper::need_minimum_chrome_version( '62.0.0.0', @_ );
WWW::Mechanize::Chrome->new(
autodie => 1,
@_,
);
};
t::helper::run_across_instances(\@instances, \&new_mech, $testcount, sub {
my ($browser_instance, $mech) = @_;
$mech->autodie(1);
$mech->get_local('50-tick.html');
my ($clicked,$type,$ok);
# Xpath
$mech->get_local('50-tick.html');
is $mech->selector('#unchecked_1',single => 1)->get_attribute('checked'), undef, "#unchecked_1 is not checked";
$mech->tick('#unchecked_1');
is $mech->selector('#unchecked_1',single => 1)->get_attribute('checked'),'checked', "#unchecked_1 is now checked";
$mech->get_local('50-tick.html');
is $mech->selector('#unchecked_1',single => 1)->get_attribute('checked'),undef, "#unchecked_1 is not checked";
$mech->tick('unchecked',3);
is $mech->selector('#unchecked_1',single => 1)->get_attribute('checked'),undef, "#unchecked_1 is not checked"
or diag $mech->selector('#unchecked_1',single => 1)->get_attribute('checked');
is $mech->selector('#unchecked_3',single => 1)->get_attribute('checked'),'checked', "#unchecked_3 is now checked"
or diag $mech->selector('#unchecked_3',single => 1)->get_attribute('checked');
$mech->get_local('50-tick.html');
is $mech->selector('#unchecked_1',single => 1)->get_attribute('checked'),undef, "#unchecked_1 is not checked";
$mech->tick('unchecked',1);
is $mech->selector('#unchecked_1',single => 1)->get_attribute('checked'),'checked', "#unchecked_1 is now checked";
is $mech->selector('#unchecked_3',single => 1)->get_attribute('checked'),undef, "#unchecked_3 is not checked";
# Now check not setting things
$mech->get_local('50-tick.html');
is $mech->selector('#unchecked_1',single => 1)->get_attribute('checked'),undef, "#unchecked_1 is not checked";
$mech->tick('unchecked',1,0);
is $mech->selector('#unchecked_1',single => 1)->get_attribute('checked'),undef, "#unchecked_1 is not checked";
is $mech->selector('#unchecked_3',single => 1)->get_attribute('checked'),undef, "#unchecked_3 is not checked";
# Now check removing checkmarks
$mech->get_local('50-tick.html');
is $mech->selector('#prechecked_1',single => 1)->get_attribute('checked'),'checked', "#prechecked_1 is checked";
$mech->tick('prechecked',1,0);
is $mech->selector('#prechecked_1',single => 1)->get_attribute('checked'),undef, "#prechecked_1 is not checked";
is $mech->selector('#prechecked_3',single => 1)->get_attribute('checked'),'checked', "#prechecked_3 is still checked";
# Now check removing checkmarks
$mech->get_local('50-tick.html');
is $mech->selector('#prechecked_1',single => 1)->get_attribute('checked'),'checked', "#prechecked_1 is checked";
is $mech->selector('#prechecked_3',single => 1)->get_attribute('checked'),'checked', "#prechecked_3 is checked";
$mech->untick('prechecked',3);
is $mech->selector('#prechecked_1',single => 1)->get_attribute('checked'),'checked', "#prechecked_1 is still checked";
is $mech->selector('#prechecked_3',single => 1)->get_attribute('checked'),undef, "#prechecked_3 is not checked";
});