关于PHPUnit的Selenium 2文档到底在哪里? [英] Where the heck is any Selenium 2 documentation for PHPUnit?
问题描述
除了在源代码和测试中可以查看"以弄清楚"的源代码和测试之外,我正试图在Selenium 2上找到有关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服务器+ 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测试用例如此兴奋的原因,因为在网络驱动程序文档中找到所需的方法后,它很容易猜测您要查找的内容.
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
内容.我在下面整理了一些链接,以使我的信息有所集中.硒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服务器命令行选项,2013年6月16日,不完整,缺少
-singleWindow
之类的内容:更多命令行选项,已使用4年: http://www. grails.org/Selenium+RC+ConfigurationSome 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 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配置XML http://phpunit.de/manual/3.7/zh-CN/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 fromSeleniumTestCase
, but thebrowser
index has changed tobrowserName
: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.这篇关于关于PHPUnit的Selenium 2文档到底在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!