#!/usr/bin/perl -w
###########################################
# emailcheck
# Mike Schilli, 2006 (m@perlmeister.com)
###########################################
use WWW::Selenium;
use Log::Log4perl qw(:easy);
Log::Log4perl->easy_init($DEBUG);

my $url = "http://perlmeister.com";

my $sel = WWW::Selenium->new(
  host => "localhost", 
  port => 4444, 
  browser => "*firefox " . 
    "$ENV{FIREFOX_HOME}/firefox-bin", 
  browser_url => $url,
);

  DEBUG "Starting";
$sel->start();

$sel->open("$url/test/mail.html");
  DEBUG "Typing email";
$sel->type("from", 'abcde');
  DEBUG "Clicking send";
$sel->click("send");
my $alert = $sel->get_alert();
  DEBUG "alert was '$alert'";

  DEBUG "Opening";
$sel->open("$url/test/mail.html");
  DEBUG "Typing email";
$sel->type("from", 'abcde@foo.com');
  DEBUG "Clicking send";
$sel->click("send");
$sel->wait_for_page_to_load(50000);
my $body = $sel->get_body_text();
  DEBUG "Response was '$body'";

$sel->stop();
