0

我正在尝试使用 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));
    }
}
4

1 回答 1

1

如果你扩展 PHPUnit_Extensions_Selenium2TestCase,你可以用这个结构计算元素:

$elements = $this->elements($this->using('xpath')->value('//li'));
$this->assertEquals(3, count($elements));
于 2013-11-01T10:53:22.590 回答