-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathtest_default_server.t
66 lines (62 loc) · 2.05 KB
/
test_default_server.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
#!/usr/bin/perl
# Copyright 2006 ThoughtWorks, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
use strict;
use warnings;
use lib 'lib';
use FindBin qw($Bin);
use File::Spec;
use Test::WWW::Selenium;
use WWW::Selenium::Util qw(server_is_running);
use Test::More;
my ($host, $port) = server_is_running();
if ($host and $port) {
plan tests => 7;
}
else {
plan skip_all => "No selenium server found!";
exit 0;
}
my $test_click_page1 = File::Spec->catfile($Bin, 'files', 'test_click_page1.html');
Regular_test: {
my $sel = Test::WWW::Selenium->new(
host => $host,
port => $port,
browser => "*firefox",
browser_url => "http://$host:$port",
verbose => 1,
);
$sel->open_ok("file://" . $test_click_page1);
$sel->text_like("link", qr/Click here for next page/, "link contains expected text");
my @links = $sel->get_all_links();
ok(@links > 3);
is($links[3], "linkToAnchorOnThisPage");
$sel->click("link");
$sel->wait_for_page_to_load(5000);
$sel->location_like(qr/test_click_page2\.html/);
$sel->click("previousPage");
$sel->wait_for_page_to_load(5000);
$sel->location_like(qr/test_click_page1\.html/);
}
HTTP_GET: {
my $sel = Test::WWW::Selenium->new(
host => $host,
port => $port,
browser => "*firefox",
browser_url => "http://$host:$port",
http_method => 'GET',
verbose => 1,
);
$sel->open_ok("file://" . $test_click_page1);
}