Selenium 3.0.1 with geckodriver 0.11.1 can't find correct option for select control

时间:2016-10-20 19:56:10

标签: selenium selenium-webdriver geckodriver

I just upgraded some functional testing code to use a newer version of Selenium and the required geckodriver, and now code that previously was selecting an option in an HTML select control is no longer working. I can reproduce the problem with a trivial page:

Here's the relevant code:

1. my_select = Select(driver.find_element_by_id("foo_select"))
2. my_select.select_by_value("3")

and the relevant HTML

<form>
    <select id="foo_select" name="foo_select">
        <option selected="selected" value="1">Ford</option>
        <option value="2">Hyundai</option>
        <option value="3">Jeep</option>
        <option value="4">Kia</option>
        <option value="5">Nissan</option>
        <option value="6">Toyota</option>
    </select>
</form>

I can check the value of my_select after 1 above and it does indeed refer to the select named "foo_select". But line 2 doesn't seem to be selecting the option with value "3" (it's not selecting anything. I've also tried the other "select_by.." variations). Indeed, if I look at my_select.first_selected_option (after 2) it still refers to the first option, "Ford".

1 个答案:

答案 0 :(得分:0)

使用Firefox 49时问题就消失了。我使用的是48。