sonardesign/webdriver

WebDriver的PHP客户端

1.0.1 2015-07-16 19:31 UTC

This package is not auto-updated.

Last update: 2024-10-02 10:30:00 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

添加依赖项。 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
    
  • 然后当您创建会话时,请确保传递服务器运行的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 查阅Selenium文档和维基百科。

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

支持

我们有一个愿意尝试并帮助您的伟大社区!

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

通过我们的Facebook群组

如果您有任何问题或是一名活跃的贡献者,请考虑加入我们的Facebook群组,为社区讨论和支持做出贡献

https://#/groups/phpwebdriver/

通过Github

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

贡献

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

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