|
Revision 1666, 0.8 kB
(checked in by kindlund, 5 months ago)
|
Added initial selenium testing.
|
| Line | |
|---|
| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
use strict; |
|---|
| 4 |
use warnings; |
|---|
| 5 |
|
|---|
| 6 |
use WWW::Selenium; |
|---|
| 7 |
|
|---|
| 8 |
my $urls = [ |
|---|
| 9 |
'http://www.google.com', |
|---|
| 10 |
'http://www.craigslist.org', |
|---|
| 11 |
]; |
|---|
| 12 |
|
|---|
| 13 |
my $sel = WWW::Selenium->new( |
|---|
| 14 |
host => "localhost", |
|---|
| 15 |
port => 4444, |
|---|
| 16 |
browser => "*iehta", |
|---|
| 17 |
browser_url => "http://localhost", |
|---|
| 18 |
); |
|---|
| 19 |
|
|---|
| 20 |
my $isStarted = 0; |
|---|
| 21 |
foreach my $url (@$urls) { |
|---|
| 22 |
if (!$isStarted) { |
|---|
| 23 |
$sel->start(); |
|---|
| 24 |
|
|---|
| 25 |
$sel->set_timeout(25000); |
|---|
| 26 |
$sel->open("/"); |
|---|
| 27 |
$sel->window_maximize(); |
|---|
| 28 |
$sel->window_focus(); |
|---|
| 29 |
$isStarted = 1; |
|---|
| 30 |
} |
|---|
| 31 |
eval { |
|---|
| 32 |
$sel->open($url); |
|---|
| 33 |
sleep(10); |
|---|
| 34 |
}; |
|---|
| 35 |
if ($@) { |
|---|
| 36 |
print "Error: " . $@ . "\n"; |
|---|
| 37 |
$sel->stop(); |
|---|
| 38 |
$isStarted = 0; |
|---|
| 39 |
} |
|---|
| 40 |
} |
|---|
| 41 |
|
|---|
| 42 |
if ($isStarted) { |
|---|
| 43 |
$sel->stop(); |
|---|
| 44 |
} |
|---|