计算类在具有代码功能的页面中出现的次数

时间:2014-01-09 04:27:38

标签: codeception

我正在使用Codeception来运行验收测试,我需要计算一个带有“.remove”类的按钮出现在一个页面中的次数。这样的按钮位于html表格内,计数取决于购物车中的物品数量 以下是我正在尝试使用的代码:

    $I->amOnPage("/cart/");
    $table = $I->grabTextFrom(".//*[@id='cart']/table");
    $rows = explode("<tr>", $table);
    $rcount = count($rows);
    while ($rcount >= 0) {
        $I->click(".remove");
        $rcount--;
    }
    $I->see("Your shopping cart is empty.");

2 个答案:

答案 0 :(得分:4)

我知道这有点晚了,但您应该尝试$ I-&gt; seeNumberOfElements,如下所述:

http://codeception.com/docs/modules/WebDriver#seeNumberOfElements

答案 1 :(得分:0)

IntArray a = fillArray()