phpunit+selenium环境筹建

WBOY
Release: 2016-06-13 13:02:26
Original
999 people have browsed it

phpunit+selenium环境搭建

这个环境搭建遇到了挺多麻烦,最终还是没能自己解决,幸好有同事“青蛙”的帮忙解决了这个问题!在这里把本人亲测步骤给大家列一下,希望给大家提供方便!

安装pear:

Go-pear.phar下载地址:http://download.csdn.net/detail/e421083458/4602207

下载go-pear.phar文件到C:\wamp\bin\php\php5.3.13\PEAR

然后执行以下命令:

cd C:\wamp\bin\php\php5.3.13
php -d phar.require_hash=0 PEAR/go-pear.phar
Copy after login


然后就是遇到回车就回车,输入Y就Y。安装之后它会提示你双击一下。

c:\wamp\bin\php\php5.3.13\PEAR_ENV.reg 以添加环境变量 照做就是。为了下面操作和以后使用方便需要将php添加到环境变量里面。

升级pear :

直接安装phpunit它会提示版本过低 这里就要升级pear了

Pear clear-cache
pear upgrade pear 
Copy after login


成功升级后的截图:


Pear upgrade-all 
Copy after login


产品升级后的截图

安装phpunit

pear clear-cache
pear channel-discover pear.phpunit.de
pear channel-discover components.ez.no
pear channel-discover pear.symfony-project.com
pear install -a -f  phpunit/PHPUnit
Copy after login


安装成功截图:


安装phpunit扩展

pear channel-discover pear.symfony.com
pear install phpunit/DbUnit
pear channel-discover pear.phpunit.de
pear install phpunit/PHPUnit_Story
Copy after login


成功截图:


安装selenium扩展

pear install phpunit/PHPUnit_Selenium
Copy after login


成功截图:


调试selenium

selenium-server-standalone-2.6.0.jar下载地址:http://download.csdn.net/detail/e421083458/4882037

打开selenium-server

java -jar C:\wamp\selenium-server-standalone-2.25.0.jar  -interactive  -log selenium.log
Copy after login


成功截图:


安装firefoxselenium IDE插件

地址:http://seleniumhq.org/download/


点击1.9.0 进行selenium IDE安装。

具体录制方法见:

http://blog.163.com/lgh_2002/blog/static/44017526201259113351146/

测试脚本:

baiduCase.php

<?php

class Example extends PHPUnit_Extensions_SeleniumTestCase

{

  protected function setUp()

  {

    $this->setBrowser("*firefox");

    $this->setBrowserUrl("http://www.baidu.com/");

  }


  public function testMyTestCase()

  {

    $this->open("/");

    $this->type("id=kw", "你好");

    $this->click("id=su");

    $this->waitForPageToLoad("30000");

    $this->assertEquals(0,0);

  }
}
?>

Copy after login


开始测试:

phpunit baiduCase.php

测试成功截图:


参考文档:

http://www.phpunit.de/manual/3.7/en/index.html

http://pear.phpunit.de/

http://seleniumhq.org/download/

 

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template