3。后一步,是怎么让程序跑起来。这里有三个问题需要注意:
1> selenium rc beta 1。0 的SSL cert已经过期了(4/18/2008),所以我们需要将我们的系统时间改回到过期之前。
$> date 041800002007
2> 需要用让selenium server使用刚刚设定好的firefox profile
3> 需要设置一个特定的参数(trustAllCertificates),让所有的SSL请求能够顺利通达。[这条在selenium正式的网站上没有写出来,是通过看源程序找到的]
我的命令如下:
让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");
---------------------------
我其实没有写什么东西,上面的程序都是selenium IDE自动录的。