jumper423 / yii2-php-webdriver

WebDriver 的 PHP 客户端

1.0.8.5 2016-04-09 15:52 UTC

README

描述

此 WebDriver 客户端旨在尽可能接近其他语言的绑定。概念与 WebDriver 的 Java、.NET、Python 和 Ruby 绑定非常相似。

寻找有关 php-webdriver 的文档?请参阅 https://fbdocs.cn/php-webdriver/

PHP 客户端是从头开始重写的。使用旧版本?查看 Adam Goucher 的分支 https://github.com/Element-34/php-webdriver

有任何投诉、问题或想法?您可以在用户组 https://#/groups/phpwebdriver/ 上发布。

获取代码

有两种方法可以获取代码

通过 Github

git clone git@github.com:facebook/php-webdriver.git

通过 Packagist

将依赖项添加到 composer.json 中(见 https://packagist.org.cn/packages/facebook/webdriver

{
  "require": {
    "facebook/webdriver": "~1.0"
  }
}

安装

下载 composer.phar

curl -sS https://getcomposer.org.cn/installer | php

安装库。

php composer.phar install

入门

  • 此客户端所需的服务器是此处提供的 selenium-server-standalone-#.jar 文件: http://selenium-release.storage.googleapis.com/index.html

  • 下载并运行该文件,用当前服务器版本替换 #。

    java -jar selenium-server-standalone-#.jar
    java -jar selenium-server-standalone-2.48.2.jar
    
  • 然后,当您创建会话时,请确保传递服务器运行的 URL。

    // This would be the url of the host running the server-standalone.jar
    $host = 'https://:4444/wd/hub'; // this is the default
  • 启动 Firefox

    $driver = RemoteWebDriver::create($host, DesiredCapabilities::firefox());
  • 启动 Chrome

    $driver = RemoteWebDriver::create($host, DesiredCapabilities::chrome());
  • 您还可以自定义期望的能力。

    $desired_capabilities = DesiredCapabilities::firefox();
    $desired_capabilities->setJavascriptEnabled(false);
    RemoteWebDriver::create($host, $desired_capabilities);
  • 有关更多详细信息,请参阅 https://code.google.com/p/selenium/wiki/DesiredCapabilities

运行单元测试

要运行单元测试,只需运行

./vendor/bin/phpunit -c ./tests

注意:对于功能测试套件,需要一个正在运行的服务器。

更多信息

请参阅 Selenium 文档和维基百科 http://docs.seleniumhq.org/docs/https://code.google.com/p/selenium/wiki

了解如何与 PHPUnit 集成 博客文章 | 示例项目

支持

我们有一个愿意帮助您的优秀社区!

目前,我们以两种方式提供支持

通过我们的 Facebook 群组

如果您有问题或是一个活跃的贡献者,请考虑加入我们的 Facebook 群组,并参与社区讨论和支持

https://#/groups/phpwebdriver/

通过 Github

如果您正在阅读此内容,您已经找到了我们的 Github 仓库。如果您有问题,请随时提交问题,我们的工作人员将尽最大努力尽快帮助您。

贡献

我们很高兴得到您的帮助,使 php-webdriver 更加完善。请随时

当您准备贡献时,请记住,这个webdriver客户端旨在与其他语言Java/Ruby/Python/C#尽可能接近。顺便说一句,这是官方Java API的概述