Ben*_*Ben 17 php phpunit functional-testing selenium-webdriver
我有一个令人沮丧的时间试图找到有关PHPUnit的Selenium 2的任何信息,除了源代码和我可以"浏览"以"弄明白"的测试.每个人的最爱似乎都是
https://github.com/sebastianbergmann/phpunit-selenium/blob/master/Tests/Selenium2TestCaseTest.php
...但我肯定不需要挖掘数百行来源来获得简单问题的答案?我在哪里可以找到初学者指南,基本文档或任何其他内容?
Ben*_*Ben 31
阿哈时刻到了.将张贴下一个可怜的灵魂在这些荒凉的混乱领域中游荡.
当Selenium说"Selenium 2"时,他们喜欢说"Selenium 2 = Selenium server + WebDriver".
对于PHPUnit的人的伎俩是webdriver的一部分,这是不是很 PHPUnit中.Selenium已经用其他几种语言编写了WebDrivers,并且还有第三方用于PHP,我没有尝试过,因为我现在正在针对PHPUnit.WebDriver基本上是一种在DOM中运行并抓取元素的方法.它在http://docs.seleniumhq.org/docs/03_webdriver.jsp上有一个很好的概述.
当PHPUnit说"Selenium 2"时,他们意味着他们编写的类可以完成WebDriver中的大部分工作,但他们并没有将其称为WebDriver,他们称之为Selenium 2.
由于PHPUnit的自制版本,它们的方法命名与Java或C#版本略有不同.这就是为什么每个人都对PHPUnit测试用例感到非常兴奋,因为在你找到webdriver文档中你想要的方法之后,它可以很容易地猜出你在寻找什么.
否则,显然PHPUnit中的大多数其他功能都坚持原始的SeleniumTestCase东西; 我在下面编了几个链接来集中我的信息.硒1不是"死",但它已经老了.PHPUnit仍然在其Selenium 1的实现中使用了很多架构,而PHPUnit的Selenium 2并不是真的,而是Selenium 1 ++.
因此,没有理由去寻找源代码,只是尝试将PHPUnit测试用例与WebDriver文档进行匹配.此外,教程中的一些方法SeleniumTestCase已更改名称Selenium2TestCase,但不要担心,事情仍然有效,只是有点混淆.
你可能会问,"为什么不用SeleniumTestCase?" 好吧,似乎对其他浏览器的支持需要WebDriver,所以如果你想要离开Firefox,你需要Selenium2TestCase(我可能是错的).
以下是我发现的一些有用的链接:
Selenium服务器命令行选项,16-06-2013,不完整,遗漏的内容如-singleWindow:http://eswarg.blogspot.com/2013/06/selenium-server-commandline-options.html
更多命令行选项,4年:http://www.grails.org/Selenium+RC+Configuration
Selenium服务器命令行帮助,到目前为止我发现的最完整的文档:
java -jar selenium-server.jar -h
命令行中的Chrome webdriver: 如何使用php webdriver获取使用selenium的chrome?
命令行中的IE webdriver:如何在PHPUnit测试中启动InternetExplorerDriver
Selenium中多个浏览器的PHPUnit配置XML 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
要解决上面的多浏览器问题,仍然可以使用静态$browser模式SeleniumTestCase,但browser索引已更改为browserName:
public static $browsers = array(
array(
'name' => 'Internet Explorer',
'browserName' => 'iexplore', // not 'browser'
'host' => 'localhost',
'port' => 4444,
'timeout' => 30000,
),
};
Run Code Online (Sandbox Code Playgroud)
请注意,<selenium>如果您使用的是XML配置,则Phing不支持该标记.