Selenium webdriver java下拉列表问题元素应已被选中
我有用于下拉列表的HTML代码:Selenium webdriver java下拉列表问题元素应已被选中,java,webdriver,Java,Webdriver,我有用于下拉列表的HTML代码: <div class="column two"> <select id="CCType" name="CCType"> <option value="">Please select...</option> <option value="Mcard">Master Card</option> <option value="Visa ">VISA</op
<div class="column two">
<select id="CCType" name="CCType">
<option value="">Please select...</option>
<option value="Mcard">Master Card</option>
<option value="Visa ">VISA</option>
</select>
selectCreditCardType.selectByVisibleText(customer.creditCardType);
或
selectCreditCardType.selectByVisibleText(customer.creditCardType);
结果:元素应为select
,但为input
selectCreditCardType.selectByVisibleText(customer.creditCardType);
尝试了stackoverflow的不同选项:
但是还没有运气。如果您使用OpenQA.Selenium.Support.UI.SelectElement类,它应该可以工作
selectCreditCardType.selectByVisibleText(customer.creditCardType);
C#示例:
selectCreditCardType.selectByVisibleText(customer.creditCardType);
您也可以按值进行操作,但这将是对select元素选项的get属性选择和比较
selectCreditCardType.selectByVisibleText(customer.creditCardType);
option.GetAttribute("value");