3。后一步,是怎么讓程序跑起來。這里有三個(gè)問題需要注意:
1> selenium rc beta 1。0 的SSL cert已經(jīng)過期了(4/18/2008),所以我們需要將我們的系統(tǒng)時(shí)間改回到過期之前。
$> date 041800002007
2> 需要用讓selenium server使用剛剛設(shè)定好的firefox profile
3> 需要設(shè)置一個(gè)特定的參數(shù)(trustAllCertificates),讓所有的SSL請求能夠順利通達(dá)。[這條在selenium正式的網(wǎng)站上沒有寫出來,是通過看源程序找到的]
我的命令如下:
讓selenium server跑起來:
java -jar ~/server/selenium-server.jar
-log /tmp/selenium.log
-trustAllSSLCertificates
-multiWindow
-firefoxProfileTemplate /opt/ipatest.profile
15:52:10.698 INFO - Writing debug logs to /tmp/selenium.log
15:52:10.699 INFO - Java: Sun Microsystems Inc. 10.0-b19
15:52:10.699 INFO - OS: Linux 2.6.18-8.el5 i386
15:52:10.702 INFO - v1.0-beta-1 [2201], with Core v1.0-beta-1 [1994]
15:52:10.758 INFO - Version Jetty/5.1.x
15:52:10.760 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
15:52:10.762 INFO - Started HttpContext[/selenium-server,/selenium-server]
15:52:10.763 INFO - Started HttpContext[/,/]
15:52:10.772 INFO - Started SocketListener on 0.0.0.0:4444
15:52:10.773 INFO - Started org.mortbay.jetty.Server@5ac072
讓測試程序跑起來:
perl test.pl
我的test.pl 程序開頭部分如下:
----------------------------
#!/usr/bin/perl
use strict;
use warnings;
use Time::HiRes qw(sleep);
use Test::WWW::Selenium;
use Test::More "no_plan";
use Test::Exception;
my $sel = Test::WWW::Selenium->new( host => "localhost",
port => 4444,
browser => "*firefox",
browser_url => "https://some.com");
$sel->open_ok("/testpage");
$sel->click_ok("link=Add User");
$sel->wait_for_page_to_load_ok("30000");
$sel->type_ok("form_title", "auto001");
$sel->type_ok("form_givenname", "selenium");
$sel->type_ok("form_sn", "001");
$sel->type_ok("form_krbprincipalkey", "redhat123");
$sel->type_ok("form_krbprincipalkey_confirm", "redhat123");
$sel->click_ok("document.form.submit[1]");
$sel->wait_for_page_to_load_ok("30000");
$sel->is_text_present_ok("s001 added!");
$sel->click_ok("link=Find Users");
$sel->wait_for_page_to_load_ok("30000");
$sel->type_ok("uid", "s101");
$sel->click_ok("//input[@value='Find Users']");
$sel->wait_for_page_to_load_ok("30000");
$sel->type_ok("uid", "s001");
---------------------------
我其實(shí)沒有寫什么東西,上面的程序都是selenium IDE自動(dòng)錄的。