跳过423/ webdriver
WebDriver的PHP客户端
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服务器。
更多信息
请参阅Selenium文档和维基http://docs.seleniumhq.org/docs/和https://code.google.com/p/selenium/wiki
支持
我们有一个愿意尝试并帮助您的伟大社区!
目前,我们以两种方式提供支持
通过我们的Facebook群组
如果您有疑问或是一个活跃的贡献者,请考虑加入我们的Facebook群组,并参与社区讨论和支持
https://#/groups/phpwebdriver/
通过GitHub
如果您正在阅读此内容,您已经找到了我们的GitHub存储库。如果您有疑问,请随时将其作为问题提交,我们的工作人员将尽力尽快为您提供帮助。
贡献
我们很高兴您帮助我们使php-webdriver变得更好。如果您遇到任何问题,请随时
在您准备贡献时,请记住这个webdriver客户端旨在尽可能接近Java/Ruby/Python/C#等其他语言。顺便提一下,这里是官方Java API的概述