Selenium 2 (WebDriver) and Phpunit?

后端 未结 11 1221
我在风中等你
我在风中等你 2020-12-23 12:01

Any one know how to use Selenium 2 with Phpunit? Are there any Selenium 2 samples in PHP?

11条回答
  •  佛祖请我去吃肉
    2020-12-23 12:27

    Currently (2017) I recommend using php-webdriver, what is AFAIK the most feature complete PHP language binding to interact with Selenium WebDriver.

    This library was rewritten in 2014 to support Selenium 2, and its API is mostly based on the official Java WebDriver bindings. This means you can also take advantage of code examples written in Java, as they can be usually simply followed in PHP. Its also written in a modern OOP way and follows standard PSR-4 namespaces and also PSR-2 coding standards.

    I would recommend this library over phpunit-selenium - as it was originally designed for Selenium 1 (though it nowadays support Selenium 2) and its API is strongly tight to PHPUnit. It also does not support some of the WebDriver features and is not up-to-date with upcomin W3C WebDriver specification.

    Php-webdriver is on the other hand independent library, but its integration with PHPUnit is quite simple - or you can use existing tools like Steward, which includes all the PHPUnit integration and provide also nice convenience layer and eg. allow to simply run multiple tests in parallel (without a need of another tools like paratest).

    There are also other testing framework integration options mentioned on the project homepage.

提交回复
热议问题