Select 来自下拉菜单在 mozilla 中不起作用

Select from drop down not working in mozilla

我有选择的代码是从下面看到的下拉列表中选择一个选项。 (代码在此之下)。 我的问题是为什么这在 Chrome 浏览器上有效,但在 Mozilla 上它除了警告它正在减慢程序外没有做任何事情?

<select class="combobox i_realm" name="realm" id="i_realm" onchange="SetCookie('realm', this.selectedIndex);">
<option value="0">-- Wybierz krainę&nbsp;&nbsp;</option>
<option value="1">&nbsp;» R1 Necropolia </option>   
<option value="2">&nbsp;» R2 Moria </option>    
<option value="3">&nbsp;» R3 Necropolia II </option>  
<option value="4">&nbsp;» R4 Necropolia III </option>  
<option value="5">&nbsp;» R5 Moria II </option>    
<option value="6">&nbsp;» R6 Necropolia IV </option>  
<option value="7">&nbsp;» R7 Necropolia V </option>   
<option value="8">&nbsp;» R8 Necro Hardcore </option>  
<option value="9">&nbsp;» R9 Moria III </option>   
<option value="10">&nbsp;» R10 Necropolia VI </option>  
<option value="11">&nbsp;» R11 Necropolia VII </option>  
<option value="12">&nbsp;» R12 Necropolia VIII </option> 
<option value="13">&nbsp;» R13 Moria IV </option>   
<option value="14">&nbsp;» R14 Necropolia IX </option>  
<option value="15">&nbsp;» R15 Moria V </option>   
<option value="16">&nbsp;» R16 Necropolia X </option>  
<option value="17">&nbsp;» R17 Moria VI </option>
<option value="18">&nbsp;» R18 Necropolia XI </option>     
</select>

WebElement element
element=driver.findElement(By.id("i_realm"));
Select select=new Select(element);
select.selectByValue("17");

在 firefox 中,我也遇到了这个问题,我曾尝试点击下拉菜单,然后点击 select 值,它正在工作。 运行 下面的代码。

代码:

WebElement 元素;

元素=driver.findElement(By.id("i_realm"));

element.click();

Select select = 新 Select(元素);

select.selectByValue("17");