-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathselenium-dwim.t
61 lines (52 loc) · 1.55 KB
/
selenium-dwim.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
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 30;
use Test::Exception;
use Test::Mock::LWP;
# Tests for enhancements to help users find their problems faster
BEGIN {
use lib 'lib';
use_ok 't::WWW::Selenium'; # subclass for testing
}
Forgot_to_open: {
my $sel = t::WWW::Selenium->new;
my $error_msg = q{You must open a page before calling getTitle. eg: $sel->open('/');};
throws_ok { $sel->get_title } qr/\Q$error_msg\E/;
}
Open_default: {
my $sel = t::WWW::Selenium->new;
lives_ok { $sel->open };
like $Mock_req->new_args->[4], qr/\Qcmd=open&1=%2F\E/, 'open specified /';
}
Double_start: {
my $sel = t::WWW::Selenium->new; # calls start() automatically
$sel->start;
is $Mock_req->new_args, undef;
}
Auto_stop: {
my $sel = t::WWW::Selenium->new;
$sel->open('/');
$sel->_set_mock_response_content('http://example.com');
$sel->get_location;
$sel = undef;
like $Mock_req->new_args->[4], qr/cmd=testComplete/, 'auto-stop';
}
Auto_stop_off: {
my $sel = t::WWW::Selenium->new(auto_stop => 0);
$sel->open('/');
$sel->_set_mock_response_content('http://example.com');
$sel->get_location;
$sel = undef;
unlike $Mock_req->new_args->[2], qr/cmd=testComplete/, 'not auto-stop';
}
Do_command_open: {
my $sel = t::WWW::Selenium->new;
$sel->do_command(qw(open /));
$sel->_set_mock_response_content('http://example.com');
lives_ok { $sel->get_location };
}
Set_timeout_before_open: {
my $sel = t::WWW::Selenium->new;
lives_ok { $sel->set_timeout(3000) };
}