0

这是代码

<select id="filter_step_id" onchange="master.updateFilter();" name="filter_step_id">
    <option value="">Step</option>
    <option value="setup">company</option>
    <option value="cofounder">co-founder</option>
    <option value="project">project</option>
    <option value="idea">idea</option>
    <option value="product">product</option>
    <option value="sell">Sell</option>
    <option value="money">money</option>
    <option value="talent">talent</option>

如何计算此下拉菜单中的选项数量并获取文本并将它们放入数组(而不是值)?

这是我得到的

$numOptions = $this->storeXpathCount("//select[contains(@id,'filter_step_id')]//option[contains(@value, '')]");
for($i = 0; $i <= $numOptions; $i ++) {
    (code to select one option and checking if the text is present from using the filter)
}
4

1 回答 1

0
$stepCount = $this->getXpathCount("//select[contains(@id,'filter_step_id')]//option[contains(@value, '')]");
    for($i = 2; $i <= $stepCount; $i ++) {
        $stepOptions = $this->getText("xpath=(//select[contains(@id,'filter_step_id')]//option[contains(@value, '')])[$i]");
        $this->select("id=filter_step_id", "label=$stepOptions");
        sleep(2);
        $this->assertTextPresent("$stepOptions");
    }
于 2012-09-26T18:07:39.280 回答