我正在使用 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.");