Chinaunix首页 | 论坛 | 博客
  • 博客访问: 32802
  • 博文数量: 8
  • 博客积分: 110
  • 博客等级: 民兵
  • 技术积分: 107
  • 用 户 组: 普通用户
  • 注册时间: 2012-11-26 14:10
文章分类

全部博文(8)

文章存档

2014年(1)

2013年(3)

2012年(4)

我的朋友

分类: Python/Ruby

2012-12-20 17:08:12

Suppose that JRE(Java Runtime Envrioment), Test::WWW::Selenium, Selenium::Remote::Driver have installed in your computer.

1. Download selenium IDE and selenium server (selenium-server-standalone-2.25.0.jar) from 

2. Write a script from Selenium IDE and save as Perl script which looks like below

点击(此处)折叠或打开

  1. use strict;
  2. use warnings;
  3. use Time::HiRes qw(sleep);
  4. use Test::WWW::Selenium;
  5. use Test::More "no_plan";
  6. use Test::Exception;
  7. use Selenium::Remote::Driver;


  8. my $sel = Test::WWW::Selenium->new( host => "localhost",
  9.                                     port => 4444,
  10.                                     browser => "*iexplore",
  11.                                     browser_url => "" );

  12. $sel->open_ok("/");
  13. $sel->click_ok("link=Chapter2");
  14. $sel->wait_for_page_to_load_ok("30000");
  15. $sel->click_ok("id=but1");
3. Start up Selenium RC Server by run the command java -jar selenium-server-standalone-2.25.0.jar

4. Run perl test case and the output should appear similar to the following code:

点击(此处)折叠或打开

  1. E:\selenium\test>ff.pl
  2. ok 1 - open, /
  3. ok 2 - click, link=Chapter2
  4. ok 3 - wait_for_page_to_load, 30000
  5. ok 4 - click, id=but1
  6. 1..4

阅读(703) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~