Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在selenium服务器上运行PHPUNIT_Php_Phpunit_Selenium Webdriver - Fatal编程技术网

在selenium服务器上运行PHPUNIT

在selenium服务器上运行PHPUNIT,php,phpunit,selenium-webdriver,Php,Phpunit,Selenium Webdriver,我正在尝试使用xpath获取元素数组,并将结果加载到数组中,然后执行assertCount()。这是我的代码。我是新手,不知道为什么elementList是空的 <?php require_once('Base.php'); class FollowupTest extends Test_Base { protected $session = null; /** * Asserts that the count of list elements on the

我正在尝试使用xpath获取元素数组,并将结果加载到数组中,然后执行
assertCount()
。这是我的代码。我是新手,不知道为什么elementList是空的

<?php

require_once('Base.php');

class FollowupTest extends Test_Base {

    protected $session = null;

    /**
    * Asserts that the count of list elements on the page is equal
    * to three utilizing an xpath expression.
    */
    public function testCountListElements() {
        $elementsList = $this->session->elements('xpath', '//li');
        $this->assertCount(3, sizeof($elementList));
    }
}

如果扩展PHPUnit\u Extensions\u Selenium2TestCase,则可以使用以下方法计算元素:


你能提供更多的细节吗?您使用的是什么Selenium服务器?您是否正在为Selenium API使用库(如PHPUnit_Selenium扩展)?什么是测试基地?这是您提供的自定义类吗?我使用的是selenium server 2.25.0(Webdriver)。Test_Base是phpunit中的一个类。这不是习俗$elementList应该是一个数组,我需要用从$this->session->elements('xpath','//li')检索到的元素加载它。我不是专家,但我认为您应该扩展Selenium2TestCase。会话()在该类上可用。我认为手册应该提供一个良好的开端:。
$elements = $this->elements($this->using('xpath')->value('//li'));
$this->assertEquals(3, count($elements));