Phpunit+selenium Environment Construction

Source: Internet
Author: User

This environment set up encountered quite a lot of trouble, finally still can not solve their own, fortunately, a colleague "frog" help solve the problem! Here put my pro-test steps to everyone listed, hope to provide you with convenience!

Install Pear:

go-pear.phar:http://download.csdn.net/detail/e421083458/4602207

Download Go-pear.phar file to C:\wamp\bin\php\php5.3.13\PEAR

Then execute the following command:

[Plain]View Plaincopyprint?
    1. CD C:\wamp\bin\php\php5.3.13
    2. php-d phar.require_hash=0 Pear/go-pear.phar

Then just hit the carriage return and enter Y on Y. After installation it will prompt you to double-click.

C:\wamp\bin\php\php5.3.13\PEAR_ENV.reg to add an environment variable. It is necessary to add PHP to the environment variables for the following operations and for later use.

Upgrade Pear:

Install PHPUnit directly it will prompt the version is too low this is going to upgrade pear.

[Plain]View Plaincopyprint?
    1. Pear Clear-cache
    2. Pear Upgrade Pear

After the successful upgrade:

[Plain]View Plaincopyprint?
    1. Pear Upgrade-all

After the product upgrade

Installing PHPUnit

[Plain]View Plaincopyprint?
    1. Pear Clear-cache
    2. Pear Channel-discover pear.phpunit.de
    3. Pear Channel-discover components.ez.no
    4. Pear Channel-discover pear.symfony-project.com
    5. Pear install-a-F phpunit/phpunit

Installation succeeded:

Installing the PHPUnit Extension

[Plain]View Plaincopyprint?
    1. Pear Channel-discover pear.symfony.com
    2. Pear Install Phpunit/dbunit
    3. Pear Channel-discover pear.phpunit.de
    4. Pear Install Phpunit/phpunit_story

The omission of such a step would result in the following error:

Invalid response while accessing the Selenium Server at ' http://localhost:4444/selenium-server/driver/': Failed to start n EW browser Session:error while launching browser

Or

Exception:unable to bind to locking port 7054 within 45000

Success:

Installing the Selenium extension

[Plain]View Plaincopyprint?
    1. Pear Install Phpunit/phpunit_selenium

Success:

Debug Selenium

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

Open Selenium-server

[Plain]View Plaincopyprint?
    1. Java-jar C:\wamp\selenium-server-standalone-2.25.0.jar-interactive-log Selenium.log

Success:

Installing the Selenium IDE plugin for Firefox

Address: http://seleniumhq.org/download/

Click 1.9.0 for Selenium IDE installation.

For specific recording methods see:

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

Test script:

baiducase.php

[PHP]View Plaincopyprint?
  1. <?php
  2. Class Example extends Phpunit_extensions_seleniumtestcase
  3. {
  4. protected function setUp ()
  5. {
  6. $this->setbrowser ("*firefox");
  7. $this->setbrowserurl ("http://www.baidu.com/");
  8. }
  9. Public function testmytestcase ()
  10. {
  11. $this->open ("/");
  12. $this->type ("id=kw", "Hello");
  13. $this->click ("Id=su");
  14. $this->waitforpagetoload ("30000");
  15. $this->assertequals (0,0);
  16. }
  17. }
  18. ?>

To start the test:

PHPUnit baiducase.php

Test success:

Reference Documentation:

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

http://pear.phpunit.de/

http://seleniumhq.org/download/

Phpunit+selenium Environment Construction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.