【发布时间】:2014-01-28 18:18:39
【问题描述】:
I use to pick items from drop-down menus using `SelectElement` class in my automated tests and they worked just fine until I upgraded to Selenium 2.39 .
ALL (!) tests that use this class fail and I get error message: `"Element is not currently visible and so may not be interacted with".`
I presume there is a bug in 2.39. Tested on Firefox 26.0. Anyone knows how to fix this problem?
//Here's a piece of my HTML:
<select id="CodGender" class="ui-selectmenu-element" name="CodGender" data-val-required="Mandatory attribute" data-val="true" aria-disabled="false">
<option value=""></option>
<option value="M">Male</option>
<option value="Z">Female</option>
</select>
//and here's how I'd pick an item from the drop-down:
{ var dropDownList = driver.FindElement(By.XPath("[@id='CodGender']"));
var selectElement = new SelectElement(dropDownList);
selectElement.SelectByText("Male");
}
这是通过第二行代码后“dropDownList”的快速观察窗口结果: 显示为假 启用 true 位置 {X = -1658 Y = 791} 选择假 尺寸 {宽度 = 200 高度 = 30} 标记名称“选择” 文字“”
... 这是 "selectElement" 的一个: AllSelectedOptions 计数 = 1 IsMultiple 错误 选项计数 = 3 [0] {OpenQA.Selenium.Firefox.FirefoxWebElement} [1] {OpenQA.Selenium.Firefox.FirefoxWebElement} [2] {OpenQA.Selenium.Firefox.FirefoxWebElement}
... 然后选项 2 看起来像: [OpenQA.Selenium.Firefox.FirefoxWebElement] {OpenQA.Selenium.Firefox.FirefoxWebElement} 显示为假 启用 true 位置 {X = -1656 Y = 851} 选择假 尺寸 {宽度 = 197 高度 = 16} 标记名称“选项” 文本 ”” ...
【问题讨论】:
-
即使通过您自己的调试,
select也是不可见的。那么用户必须做什么才能使其可见呢?
标签: c# drop-down-menu selenium-webdriver