1
我必須選擇從下拉菜單中的選項,HTML代碼是Python的硒:選擇選項
<select id="formIdVeic" style="width: 250px; display: none;" class="combobox-f combo-f" comboname="formIdVeic">
<option value="" selected="selected"></option>
<option value="E">TARGA ESTERA </option>
<option value="J">TARGA FILOBUS </option>
<option value="L">TELAIO </option>
<option value="TN" selected="selected">TARGA ITALIANA NUOVO FORMATO </option>
<option value="TS">TARGA ITALIANA SPECIALE </option>
<option value="TV">TARGA ITALIANA VECCHIO FORMATO </option>
<option value="X">TARGA PROVA </option>
<option value="Y">TARGA PROVVISORIA </option>
</select>
我要選擇「電視」選項。我來的解決方案是
from selenium.webdriver.support.select import Select
...
a=Select(browser.find_element_by_xpath('//select[@id="formIdVeic"]'))
a.select_by_visible_text("TARGA ITALIANA VECCHIO FORMATO").click()
或
a.select_by_value("TV").click()
,其中瀏覽器是Web瀏覽器的驅動程序。這兩種解決方案都會返回一個異常:
ElementNotVisibleException: element not visible:
Element is not currently visible and may not be manipulated
我在哪裏做錯了?
你必須顯示在樣式定義 – Eugene
「無」你是什麼意思? –
style =「width:250px; display:none;」 – Eugene