1 # run this file from within Cygwin (or on a 'real' Unix) using the
\r
2 # prove command line tool. prove is a script, and is part of
\r
3 # the Test::Harness perl module.
\r
5 # I (Gordon) have added an alias to Cygwin to ease running this test
\r
6 # alias potoss='export POT_TEST_DIR=oss ; prove /cygdrive/i/potoss_alias/potoss_code/selenium.selt'
\r
8 # you will also need to install the Selenium Remote Control application
\r
13 # Don't set the number of tests in the Test::More definition
\r
14 # rather, set them based on the number of browsers you'll be testing.
\r
15 # This is done automatically with the "plan" function call below.
\r
17 use Test::WWW::Selenium;
\r
19 my $NUM_TESTS_PER_BROWSER = 89;
\r
20 my $SELENIUM_SERVER_DIR =
\r
21 qq~"C:\\Program Files\\selenium-remote-control-0.9.1_nightly\\server"~;
\r
24 { name => 'firefox', should_test => 1 },
\r
25 { name => 'iexplore', should_test => 0 },
\r
26 { name => 'opera', should_test => 0 }, # works, but gives a little popup error.
\r
29 my @browsers_to_test = grep({$_->{should_test}} @BROWSERS);
\r
31 # automatically set the number of Test::More tests based on the
\r
32 # number of browsers you plan to test.
\r
33 plan( tests => $NUM_TESTS_PER_BROWSER * scalar(@browsers_to_test) );
\r
35 # start up the Selenium server in java
\r
36 # send STDERR to /dev/null so no 'clutter' messages appear in the console
\r
38 cd $SELENIUM_SERVER_DIR ;
\r
39 java -jar selenium-server.jar 2> /dev/null &
\r
46 my $test_dir = $ENV{POT_TEST_DIR}
\r
47 || die "needs POT_TEST_DIR environmental variable set";
\r
51 url => 'www.potoss_dev.com', # you can set this in your HOSTS file
\r
53 texts => '/cygdrive/i/potoss_dev_alias/potoss_data/texts_8s73f9dv/',
\r
55 #TEMPLATE_ADD_EXTRA_SELENIUM_TEST_DIRS
\r
58 my $url = $test_for{$test_dir}->{url} || die "need url for test_dir";
\r
59 my $dir = $test_for{$test_dir}->{dir} || die "need dir for test_dir";
\r
60 my $texts_dir = $test_for{$test_dir}->{texts} || die "need texts for test_dir";
\r
63 for my $browser (@browsers_to_test) {
\r
65 $sel = Test::WWW::Selenium->new(
\r
66 host => "localhost",
\r
68 browser => "*$browser->{name}",
\r
69 browser_url => "http://$url/",
\r
73 $sel->open_ok("${dir}potoss_saved_test");
\r
75 $sel->is_text_present_ok("edit this page");
\r
76 $sel->is_text_present_ok("this is change 11");
\r
80 $sel->click_ok("link=advanced options");
\r
82 $sel->click_ok("link=show the page's revision history");
\r
84 $sel->click_ok("link=compare two revisions");
\r
86 $sel->click_ok("link=start at revision 9");
\r
88 $sel->click_ok("link=end at revision 10");
\r
90 $sel->is_text_present_ok("this is change 10");
\r
94 $sel->open_ok("${dir}potoss_wow"); #read only alias for potoss_saved_test
\r
96 $sel->is_text_present_ok("read only");
\r
97 $sel->is_text_present_ok("this is change 11");
\r
99 $sel->open_ok("${dir}PH_edit&nm_page=potoss_wow");
\r
101 $sel->is_text_present_ok("You can't edit this page");
\r
103 $sel->open_ok("${dir}PH_page_opts&nm_page=potoss_wow");
\r
105 $sel->is_text_present_ok("You can't view this page's options");
\r
107 $sel->open_ok("${dir}potoss_tmp_test");
\r
109 $sel->is_text_present_ok("This page doesn't exist");
\r
110 $sel->click_ok("link=create it as a new page");
\r
112 $sel->click_ok("id=myel_new_page");
\r
114 $sel->is_text_present_ok("edit this page");
\r
115 $sel->click_ok("link=edit this page");
\r
117 $sel->is_text_present_ok("This message only appears the first time you edit a page");
\r
118 $sel->type_ok("myel_text_area", "This is some text.");
\r
119 $sel->click_ok("nm_submit");
\r
121 $sel->is_text_present_ok("This is some text");
\r
122 $sel->click_ok("link=edit this page");
\r
124 $sel->type_ok("myel_text_area", "This is some text.\nThis is even more text.");
\r
125 $sel->click_ok("nm_submit");
\r
127 $sel->is_text_present_ok("This is even more text");
\r
128 $sel->click_ok("link=advanced options");
\r
130 $sel->click_ok("link=show the page's revision history");
\r
132 $sel->is_text_present_ok("view revision 2");
\r
134 `cd $texts_dir ; rm -r potoss_tmp_test_REVS ; rm potoss_tmp_test*`;
\r
136 #-------------------------------------------------------------------------
\r
138 # When there is only a single revision, a message appears when you try
\r
139 # to look at the revisions.
\r
141 $sel->open_ok("${dir}potoss_tmp_test");
\r
143 $sel->is_text_present_ok("This page doesn't exist");
\r
144 $sel->click_ok("link=create it as a new page");
\r
146 $sel->click_ok("id=myel_new_page");
\r
148 $sel->is_text_present_ok("edit this page");
\r
149 $sel->click_ok("link=edit this page");
\r
151 $sel->is_text_present_ok("This message only appears the first time you edit a page");
\r
152 $sel->type_ok("myel_text_area", "This is some text.");
\r
153 $sel->click_ok("nm_submit");
\r
155 $sel->click_ok("link=advanced options");
\r
157 $sel->click_ok("link=show the page's revision history");
\r
159 $sel->is_text_present_ok("There is currently only one revision");
\r
161 `cd $texts_dir ; rm -r potoss_tmp_test_REVS ; rm potoss_tmp_test*`;
\r
163 #-------------------------------------------------------------------------
\r
165 # Try to create a page name which is in the dictionary
\r
166 $sel->open_ok("${dir}PH_create");
\r
167 $sel->is_text_present_ok("like the page name");
\r
168 $sel->type_ok("myel_page_name", "queen");
\r
169 $sel->click_ok("nm_submit");
\r
171 $sel->is_text_present_ok("is in the dictionary");
\r
173 #-------------------------------------------------------------------------
\r
175 # Try to create a page which already exists
\r
176 $sel->open_ok("${dir}PH_create");
\r
177 $sel->is_text_present_ok("like the page name");
\r
178 $sel->type_ok("myel_page_name", "potoss_saved_test");
\r
179 $sel->click_ok("nm_submit");
\r
181 $sel->is_text_present_ok("that one already exists");
\r
183 #-------------------------------------------------------------------------
\r
185 # Try to create a wrong page name. It will automatically suggest a
\r
187 $sel->open_ok("${dir}PH_create");
\r
188 $sel->is_text_present_ok("like the page name");
\r
189 $sel->type_ok("myel_page_name", "My dog is always hungry!");
\r
190 $sel->click_ok("nm_submit");
\r
192 $sel->is_text_present_ok("changed the page name to");
\r
193 $sel->is_text_present_ok("my_dog_is_always_hungry");
\r
195 sleep 2; #see what happened in the browser window before you close it.
\r
200 # If there is still an sel object, then send the Remote Control the command
\r
201 # to shutDown, which will cause the Java process to end. This is not
\r
202 # documented directly in the Test::WWW::Selenium documentation, but the
\r
203 # shutDown command is shown in the Selenium Remote Control documentation.
\r
204 $sel && $sel->do_command("shutDown");
\r
207 # this is called so often that it should be a subroutine
\r
208 # with a cleaner name and a variable you can change in one place.
\r
209 $sel->wait_for_page_to_load_ok('30000', 'page loads in less than 30000');
\r