无法从下拉列表中选择一个选项

时间:2016-06-13 12:33:02

标签: selenium selenium-webdriver drop-down-menu

我有以下html:

<select id="80211Mode_5" onchange="ChangeWidthList('5')" name="80211Mode_5" sb="74332008" style="display: none;">
  <option value="802.11a">802.11a only</option>
  <option value="802.11n">802.11n only</option>
  <option value="802.11an">Mixed 802.11a/n</option>
  <option value="802.11ac">802.11ac only</option>
  <option value="802.11nac">Mixed 802.11n/ac</option>
  <option value="802.11anac">Mixed 802.11a/n/ac</option>
</select>

我想遍历所有下拉选项。我可以从下拉框中选择除802.11n以外的所有选项。

当我尝试选择802.11n时,我收到ElementNotVisibleException exception。来自html 802.11n看起来只是可见的。为什么我无法选择802.11n选项,特别是以下代码:

def dlink_change_channel(self, channel):
    try:
        # Change channel in Dlink router
        self.login()
        self.browser_driver.find_element_by_id("menu_Settings").click()
        self.browser_driver.find_element_by_link_text("Wireless").click()
        self.browser_driver.find_element_by_css_selector("#RADIO_5GHz > div.advButton").click()
        self.browser_driver.execute_script("document.getElementsByClassName('sbOptions')[11].style.display='inline-block';")
        self.browser_driver.execute_script("document.getElementsByClassName('sbOptions')[11].scrollIntoView();")
        self.browser_driver.execute_script("document.getElementsByClassName('sbOptions')[11].click();")
        channel_xpath = "//a[@href="+"\'"+channel+"\'"+"]"
        print channel_xpath
        time.sleep(1)
        self.browser_driver.find_element_by_xpath(channel_xpath).click()
        time.sleep(1)
        self.browser_driver.find_element_by_id("Save_btn").click()
        time.sleep(1)
        self.browser_driver.execute_script("document.getElementById('sumbit_CheckData').click();")
        time.sleep(20)
        self.browser_driver.find_element_by_id("Confirm_btn").click()
        time.sleep(1)
        self.browser_driver.close()

我正在从另一个函数传递channeldlink_change_channel功能(我从循环中逐个传递802.11a802.11n等等)

1 个答案:

答案 0 :(得分:-1)

以下代码正在运行:

postsRepository.GetByAuthor("Bob").GetPage(5, 10);