cargomedia/webnavigator

此包已被废弃且不再维护。未建议替代包。

0.1.2 2016-02-26 14:49 UTC

This package is not auto-updated.

Last update: 2020-01-24 15:48:51 UTC


README

此项目不再维护。如果您想接管,请联系我们 tech@cargomedia.ch

webnavigator Build Status

为简单的自动化验收测试提供 facebook/php-webdriver 的包装。

PhantomJS

WebNavigator 可以连接到 WebDriver 服务器 PhantomJS。在控制台启动 PhantomJS,如下所示

phantomjs --webdriver=4444 --ssl-protocol=tlsv1 --ignore-ssl-errors=true

示例

PHPUnit 测试用例中设置 WebNavigator 实例并进行一些基本测试

class MyTest extends \PHPUnit_Framework_TestCase {

    /** @var \WebNavigator\Navigator */
    private $_navigator;

    protected function setUp() {
        $capabilities = new \DesiredCapabilities([\WebDriverCapabilityType::BROWSER_NAME => 'phantomjs']);
        $driver = \RemoteWebDriver::create('http://localhost:4444/wd/hub', $capabilities);
        $this->_navigator = new \WebNavigator\Navigator($driver, 'https://www.denkmal.org');
    }

    protected function tearDown() {
        $this->_navigator->quit();
    }

    public function testAddPage() {
        $this->_navigator->get('/events');

        $this->_navigator->click('.addButton a');
        $this->_navigator->waitForElement('.Denkmal_Page_Add');
        $this->assertContains('Event hinzufügen', $this->_navigator->getText('h1'));
        $this->assertContains('/add', $this->_navigator->getUrl());

        $this->_navigator->takeScreenshot('screenshot.png');
    }
}

开发

安装依赖

composer install

在运行测试之前,请确保您已安装 phantomjs 和一个正在运行的 web 服务器

phantomjs --webdriver=4444 &
php -S localhost:1234 -t tests/data/ &

然后运行测试

php vendor/bin/phpunit