欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

phpunit+selenium环境筹建

程序员文章站 2022-06-12 16:23:03
...
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.13php -d phar.require_hash=0 PEAR/go-pear.phar

phpunit+selenium环境筹建

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

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

升级pear :

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

Pear clear-cachepear upgrade pear 


成功升级后的截图:

phpunit+selenium环境筹建

Pear upgrade-all 


产品升级后的截图

phpunit+selenium环境筹建

安装phpunit

pear clear-cachepear channel-discover pear.phpunit.depear channel-discover components.ez.nopear channel-discover pear.symfony-project.compear install -a -f  phpunit/PHPUnit


安装成功截图:

phpunit+selenium环境筹建

安装phpunit扩展

pear channel-discover pear.symfony.compear install phpunit/DbUnitpear channel-discover pear.phpunit.depear install phpunit/PHPUnit_Story


成功截图:

phpunit+selenium环境筹建

安装selenium扩展

pear install phpunit/PHPUnit_Selenium


成功截图:

phpunit+selenium环境筹建

调试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


成功截图:

phpunit+selenium环境筹建

安装firefoxselenium IDE插件

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

phpunit+selenium环境筹建

点击1.9.0 进行selenium IDE安装。

具体录制方法见:

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

测试脚本:

baiduCase.php

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);  }}?>


开始测试:

phpunit baiduCase.php

测试成功截图:

phpunit+selenium环境筹建

参考文档:

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

http://pear.phpunit.de/

http://seleniumhq.org/download/

phpunit+selenium环境筹建

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。

相关文章

相关视频