我需要自动化在php上制作的网站,并且我的主管建议我使用webdriver和php作为编程语言。
我正在使用Mac Os X 10.6.8.
我安装了mamp
来获取php
,然后尝试安装Pear and phpunit
。
我在终端上使用几个命令成功安装了Pear,现在我可以在php5.5.3中看到pear,peardev和phar.phar文件 - > bin
然后我以某种方式安装了phpunit,现在我可以在phpunit.phar
中看到php5.5.3 -> bin
请告诉我上面提到的东西是否足以让phpunit工作?
另外请帮我安装selenium webdriver for php和所有必需的库。
我是自动化的新手。一步一步的信息将非常明显。
谢谢, Ashalina
答案 0 :(得分:1)
Installation 试试这个网站,他在每一步都解释了如何安装所需的一切。
我将把它粘贴到这里:
致信史蒂文乔治!
安装Pear
注意:您在PHP和梨的路径上不能有任何空间。因此,请确保PHP没有安装在“程序文件”目录中,否则您将永远无法从命令行中获取工作。
Download PEAR
Extract the archive using WinRAR
Create a “PEAR” directory in C:\PHP
Copy the contents of the PEAR-x.x.x directory to the PEAR directory you just created
Download Console Getopt, Archive Tar, and Structures Graph
Create the directory c:\PHP\PEAR\Console. Unzip and copy “Getopt.php” from the Console Getopt zip file into it.
Create the directory c:\PHP\PEAR\Archive. Unzip and copy “Tar.php” from the ArchiveTar zip file into it.
Create the directory c:\PHP\PEAR\Structures. Unzip and copy “Graph.php” and the contents of the “Graph” directory from the Structures Graph zip file into it.
Edit your php.ini and add your php PEAR directory to your include_path
Edit your system environment variables as follows:
PHP_PEAR_BIN_DIR = C:\PHP\PEAR\scripts\
PHP_PEAR_INSTALL_DIR = C:\PHP\PEAR\
PHP_PEAR_PHP_BIN = C:\PHP\php.exe
Add C:\PHP\PEAR\scripts to your “Path” environment variable
Run a command prompt as Administrator
cd to C:\PHP\PEAR\scripts
Create a pear.ini file in c:\Windows. Alter the permissions so that any user can write to and modify it.
Run the following commands:
pear config-set auto_discover 1
pear config-set bin_dir c:\PHP\PEAR\scripts
启用cURL
Copy php_curl.dll from the php “ext” directory to the Windows System32 directory
Edit php.ini and uncomment the line that references the cURL extension.
安装PHPUnit
You need to install specific versions of PHPUnit components if you are running Zend Framework 1.x (see: http://dustyreagan.com/downgrade-phpunit-3-6-to-3-5-15/). From the administrative command prompt you opened earlier, run the commands:
pear channel-discover pear.phpunit.de
pear install --alldeps --force phpunit/PHPUnit
pear install phpunit/DbUnit
pear install phpunit/PHPUnit_Selenium
pear install phpunit/PHPUnit_Story
安装Java JRE
Download JRE
Install it as normal
安装Selenium
Download Selenium Server
Create a directory called “Selenium” in C:\Program Files\Java\jre7\bin
Copy the file you downloaded in step 1 into this directory. It should be called “selenium-server-standalone-x.xx.x.jar”
Create a new MS batch file called Selenium.bat on your desktop. Inside, type the command
java -jar "c:\Program Files\Java\jre7\bin\Selenium\selenium-server-standalone-2.25.0.jar” (note: Include the quotation marks and substitute the version number for the version you downloaded)
下载PHP webdriver库
I like the Facebook one: https://github.com/facebook/php-webdriver
运行Selenium
Execute the bat file you created for Selenium above. This will lauch the selenium service that will listen for incoming commands from your test scripts.
现在您已准备好使用PHP webdriver库编写PHPUnit测试。当您运行批处理文件时,该库将通过它打开的端口(4444)与Selenium通信。