basic working code, needs more hammering and testing
Chris Nehren [Thu, 16 Dec 2010 12:11:34 +0000 (07:11 -0500)]
.gitignore [new file with mode: 0644]
basic.html [new file with mode: 0644]
lib/Test/Harness/Selenium.pm
t [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..1ee84da
--- /dev/null
@@ -0,0 +1 @@
+*.sw*
diff --git a/basic.html b/basic.html
new file mode 100644 (file)
index 0000000..28e8497
--- /dev/null
@@ -0,0 +1,31 @@
+<html>
+<body>
+<table border="1" class="docutils" id="google-search-example">
+<colgroup>
+<col width="32%" />
+<col width="47%" />
+<col width="21%" />
+</colgroup>
+<tbody valign="top">
+<tr><td>open</td>
+<td>/</td>
+
+<td>&nbsp;</td>
+</tr>
+<tr><td>type</td>
+<td>q</td>
+<td>selenium rc</td>
+</tr>
+<tr><td>clickAndWait</td>
+<td>btnG</td>
+<td>&nbsp;</td>
+</tr>
+<tr><td>textLike</td>
+
+<td>Searches related to selenium rc</td>
+<td>&nbsp;</td>
+</tr>
+</tbody>
+</table>
+</body>
+</html>
index defe00f..d4eda0e 100644 (file)
@@ -2,7 +2,7 @@ package Test::Harness::Selenium;
 use strictures 1;
 
 use File::Find;
-use WWW::Selenium;
+use Socialtext::WikiFixture::Selenese;
 use HTML::TableExtract;
 use IO::All;
 
@@ -27,19 +27,25 @@ BEGIN {
   }
 }
 
+sub new {
+  my ($class, $self) = @_;
+  bless $self, $class;
+}
+
 sub test_directory {
-  my ($self) = @_;
-  my @tests = File::Find::Rule->file()->name('*.html')->in($self->{dir});
+  my ($self, $dir) = @_;
+  my @tests = File::Find::Rule->file()->name('*.html')->in($dir);
   $self->run_tests_for($_) for @tests;
 }
 
 sub run_tests_for {
   my ($self, $html_file) = @_;
   my $rows = $self->get_rows_for($html_file);
-  my $src = WWW::Selenium->new(
-    host => $args->{host},
-    port => $args->{port},
-    browser_url => $args->{browser_url},
+  my $src = Socialtext::WikiFixture::Selenese->new(
+    host => $self->{host},
+    port => $self->{port},
+    browser => $self->{browser},
+    browser_url => $self->{browser_url},
   );
   $src->run_test_table($rows);
 }
diff --git a/t b/t
new file mode 100644 (file)
index 0000000..b6430f1
--- /dev/null
+++ b/t
@@ -0,0 +1,14 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+use lib 'lib';
+use Test::Harness::Selenium;
+
+my $s = Test::Harness::Selenium->new({
+    host => 'localhost',
+    port => 4444,
+    browser_url => 'http://www.google.com',
+    browser => shift,
+});
+$s->run_tests_for('basic.html');