2017-02-21 82 views
0

我已经使用选项 - >格式转换器创建了许多硒IDE文件,我在Firefox IDE 2.9.1.1(Windows窗口中)中将其转换为phpunit格式。这些转换后的文件定义了一个类“Example”,它是从类PHPUnit_Extensions_SeleniumTestCase派生而来的。我现在知道这个类需要更改为PHPUnit_Extensions_Selenium2TestCase。问题是,我不能用最新版本的phpunit来运行它。获取phpunit导出的selenium IDE文件在WebDriver中运行

我正在使用php 5.6.30,java 1.8.0_121-b14和firefox 51.0.1-2的Fedora 24虚拟机上运行这些测试。我试图让这些使用硒独立服务器3.0.1(现在3.1.0)和phpunit 5.7.13运行。我安装了最新的php facebook WebDriver。我不断收到的错误是上面提到的类没有找到。我做了这个类的一个grep和这是我发现:

[[email protected] bin]# grep -r "PHPUnit_Extensions_Selenium2TestCase" .

Binary file ./phpunit/phpunit-4.6.7.phar matches

Binary file ./phpunit/phpunit-4.7.6.phar matches

所以,看来这班不PHPUnit的5.7及以上(这是在该目录)的存在,也没有在HTML中存在-runner.phar,它位于同一目录中。 seleniumhq.org网站说,如果你从IDE转换,使用html runner,但我不能找到如何使用html-runner.phar文件的示例(也没有文档)。

有人可以告诉我什么,我应该改变类名,以获得此测试工作?

UPDATE:

现在我知道,如果我想使用的PHPUnit和硒服务器驱动firefox浏览器,我得硒交谈geckodriver。我已经安装:

geckodriver 0.14.0 at /usr/local/bin/geckodriver

selenium server 3.0.1 at /usr/local/bin/selenium

phpunit-5.7.13.phar installed at /usr/local/bin/phpunit

I used composer to add webdrivers (facebook 1.3.0 :

[[email protected] composer]# cat composer.json { "require": { "facebook/webdriver": "^1.3", "phpunit/phpunit": ">=3.7", "phpunit/phpunit-selenium": ">=1.2" } }

php composer.phar install

他们被添加到PATH:

[[email protected] projects]$ echo $PATH /usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/usr/local/bin/selenium:/usr/local/bin/phpunit:/usr/local/bin/composer:/usr/local/bin/geckodriver

我有一个小的测试文件:

?php

require_once('/usr/local/bin/composer/vendor/autoload.php');

class test extends PHPUnit_Extensions_Selenium2TestCase

{

protected function setUp()

{

$this->setBrowser("*firefox"); 

$this->setBrowserUrl("https://fakeurl.com/"); 

}

public function testMyTestCase()

{

$this->open("/"); 

}

}

启动硒服务器:

java -jar /usr/local/bin/selenium/selenium-standalone-3.0.1.jar

当我运行测试:

/usr/local/bin/phpunit/phpunit-5.7.13.phar --verbose test.php

息率这样的错误:

PHPUnit_Extensions_Selenium2TestCase_WebDriverException: The best matching driver provider Firefox/Marionette driver can't create a new driver instance for Capabilities [{browserName=*firefox}]

所以,看来geckodriver就是不说话硒服务器。如果我试图通过改变服务器的执行强制问题:

java -Dwebdriver.gecko.driver="/usr/local/bin/geckodriver/geckodriver" -jar /usr/local/bin/selenium-server-standalone-3.0.1.jar

sudo java -Dwebdriver.gecko.driver="/usr/local/bin/geckodriver/geckodriver" -jar /usr/local/bin/selenium-server-standalone-3.0.1.jar

这没有什么区别。我希望有人能指出我缺少的东西。我处于死胡同。

回答

0

我目前通过得到这个同样的过程努力工作,想指出的几件事情:

  • htmlrunner是指运行在默认情况下直接从硒IDE保存测试用例格式,这是HTML。
  • 确保您可以从运行selenium服务器的终端运行firefox。
  • 您添加了两个不同的硒php绑定。 facebook one和phpunit-selenium。我目前只使用facebook绑定和phpunit来扩展类PHPUnit_Framework_TestCase。我建议使用github提供的facebook/webdriver中没有phpunit的示例来验证您的selenium配置是否正常,然后添加phpunit。
+0

我已经开始使用htmlrunner。目前为止没有成功。 Firefox确实在终端窗口中运行。我无法得到github的例子。我收到一个错误:“Error:Class'WebDriverCapabilityType'not found。我在评论中看到其他人有同样的问题,但他们的解决方案不适合我。 –

相关问题