如何在Selenium WebDriver中找到选择选项元素?

时间:2014-12-08 15:35:10

标签: selenium selenium-webdriver webdriver

我在下面有以下HTML代码:如何找到并点击任何选项,例如' verve'?

<div id="cardsSelectList">
<select id="cardtype" class="selinput" tabindex="1" onchange="webpay.ProcessCardTypeSelection($(this).val())" name="cardtype">
<option value="-1">- Select your card type -</option>
<option value="1|1|1|Card Number|0|Card PIN|1|0|||0|0">Verve\u2122</option>
<option value="1|1|1|Card Number|0|Card PIN|1|0|||0|0">MasterCard\u2122 Naira Debit</option>
<option value="1|0|1|Card Number|0|Card PIN|0|0|||0|0">Visa</option>
</select>

1 个答案:

答案 0 :(得分:0)

使用Select

@FindBy(id="cardtype")
private WebElement selectElement;
Select select = new Select(selectElement);
select.selectByValue("1|1|1|Card Number|0|Card PIN|1|0|||0|0");

您还可以选择text, index etc。参考this

用java编写并引用java。但是对于任何其他绑定,api非常相似

相关问题