PHPUnit 的 Selenium 2 文档到底在哪里?
我很难找到关于 Selenium 2 for PHPUnit 的任何信息,但我可以查看"以弄清楚"的源代码和测试除外.每个人的最爱似乎是
I'm having a frustrating time trying to find any information on Selenium 2 for PHPUnit except for source code and tests that I can "look through" to "figure it out". Everyone's favorite seems to be
https://github.com/sebastianbergmann/phpunit-selenium/blob/master/Tests/Selenium2TestCaseTest.php
...但我肯定不必挖掘数百行源代码来获得简单问题的答案吗?我在哪里可以找到初学者指南、基本文档或任何东西?
...but surely I don't have to dig through hundreds of lines of source to get answers to simple questions? Where can I find a beginner's guide, basic documentation, or anything?
推荐答案
啊哈时刻到了.将为下一个在这些荒凉混乱的领域徘徊的可怜灵魂发帖.
Ah-ha moment reached. Will post for the next poor soul wandering in these desolate fields of confusion.
当Selenium说Selenium 2"时,他们喜欢说Selenium 2 = Selenium server + WebDriver".
When Selenium says "Selenium 2", they like to say "Selenium 2 = Selenium server + WebDriver".
PHPUnit 人的诀窍在于 WebDriver 部分,这在 PHPUnit 中相当.Selenium 已经用其他几种语言编写了 WebDrivers,还有一些用于 PHP 的第三方驱动程序,因为我现在的目标是 PHPUnit,所以我没有尝试过.WebDriver 基本上是一种在 DOM 中运行并抓取元素的方式.它在 http://docs.seleniumhq.org/docs/03_webdriver.jsp一个>.
The trick for the PHPUnit person is the WebDriver part, which is not quite in PHPUnit. Selenium has written the WebDrivers in a few other languages, and there's third party ones for PHP which I haven't tried since I'm targeting PHPUnit for now. The WebDriver is basically a way of running around in the DOM and grabbing elements. It's got a good rundown at http://docs.seleniumhq.org/docs/03_webdriver.jsp.
当 PHPUnit 说Selenium 2"时,他们的意思是他们编写的类可以在 WebDriver 中完成大部分的工作,但它们是不是称它为 WebDriver,而是称它为 Selenium 2.
When PHPUnit says "Selenium 2", they mean that they've written classes which do most of the stuff in a WebDriver, but they're not calling it a WebDriver, they're calling it Selenium 2.
由于 PHPUnit 的自制版本,它们的方法命名与 Java 或 C# 版本略有不同.这就是为什么每个人都对 PHPUnit 测试用例 因为在 webdriver 文档中找到您想要的方法后,您可以轻松猜测您要查找的内容.
Because of PHPUnit's homebrewed version, their methods are named a little differently than the Java or C# versions. This is why everyone is so excited about the PHPUnit test case because it makes it easy to guess what you're looking for after you've found the method you want at the webdriver docs.
否则,显然 PHPUnit 中的大多数其他功能都坚持原来的 SeleniumTestCase
东西;我在下面编译了一些链接来集中我的信息.Selenium 1 并没有死",但它已经过时了.PHPUnit 仍然使用 Selenium 1 的实现中的很多架构,而 PHPUnit 的 Selenium 2 并不是真正的那样,而是某种 Selenium 1++.
Otherwise, apparently most of the other functionality in PHPUnit sticks to the original SeleniumTestCase
stuff; I've compiled a few links below to centralize my info somewhat. Selenium 1 is not "dead", but it is old. PHPUnit still uses a lot of architecture from its implementation of Selenium 1, and PHPUnit's Selenium 2 is not really that, but sort of Selenium 1++.
因此,没有理由去寻找源代码,只需尝试将 PHPUnit 测试用例与 WebDriver 文档匹配即可.此外,SeleniumTestCase
教程中的一些方法已经在 Selenium2TestCase
中更改了名称,但不用担心,事情仍然是一样的,只是有点混淆了.
So, there's no reason to go hunting through the source, just try to match the PHPUnit test cases to the WebDriver docs. Also, a few methods in the tutorial for SeleniumTestCase
have changed names in Selenium2TestCase
, but fear not, the thing still works the same, just a little obfuscated.
您可能会问,为什么不直接使用 SeleniumTestCase
?"好吧,看来支持其他浏览器需要WebDriver,所以如果你想退出Firefox,你需要Selenium2TestCase
(我可能错了).
You may ask, "Why not just use SeleniumTestCase
?" Well, it seems that support for other browsers requires the WebDriver, so if you want to get out of Firefox, you'll need Selenium2TestCase
(I could be wrong).
以下是我发现的一些有用的链接:
Here's some helpful links I found as I scraped away at this:
Selenium 服务器命令行选项,16-06-2013,不完整,缺少诸如
-singleWindow
之类的内容:http://eswarg.blogspot.com/2013/06/selenium-server-commandline-options.html
更多命令行选项,4 岁:http://www.grails.org/Selenium+RC+配置
Some more command line options, 4 years old: http://www.grails.org/Selenium+RC+Configuration
Selenium 服务器命令行帮助,迄今为止我找到的最完整的文档:java -jar selenium-server.jar -h
Selenium server command line help, the most complete documentation I've found so far:
java -jar selenium-server.jar -h
来自命令行的 Chrome 网络驱动程序:如何使用 php webdriver 让 Chrome 与 selenium 一起工作?
Chrome webdriver from command line: How do I get chrome working with selenium, using php webdriver?
命令行中的 IE webdriver:如何在 PHPUnit 测试中启动 InternetExplorerDriver一个>
IE webdriver from command line: Howto start InternetExplorerDriver in PHPUnit tests
Selenium 中多个浏览器的 PHPUnit 配置 XMLhttp://phpunit.de/manual/3.7/en/appendixes.configuration.html#appendixes.configuration.selenium-rc
PHPUnit configuration XML for multiple browsers in Selenium http://phpunit.de/manual/3.7/en/appendixes.configuration.html#appendixes.configuration.selenium-rc
Selenium2TestCase
类的文档 (!) http://apigen.juzna.cz/doc/sebastianbergmann/phpunit-selenium/class-PHPUnit_Extensions_Selenium2TestCase.html
当然还有神秘的 PHPUnit Selenium 文档:http://phpunit.de/manual/3.7/en/selenium.html
And, of course, the enigmatic PHPUnit Selenium docs: http://phpunit.de/manual/3.7/en/selenium.html
要解决我上面的多浏览器问题,仍然可以使用 SeleniumTestCase
中的静态 $browser
模式,但 browser
索引已更改为 browserName
:
To solve my multiple-browser question above, it's still possible to use the static $browser
pattern from SeleniumTestCase
, but the browser
index has changed to browserName
:
public static $browsers = array(
array(
'name' => 'Internet Explorer',
'browserName' => 'iexplore', // not 'browser'
'host' => 'localhost',
'port' => 4444,
'timeout' => 30000,
),
};
请注意,如果您使用 XML 配置,Phing 不支持 <selenium>
标记.
Note that Phing does not support the <selenium>
tag if you're using an XML config.
相关文章