2014-04-01 139 views
0
<th id="id1" class="LockedColumnForTable" nowrap="nowrap" index="1" level="1" path="db" name="db" style="padding:0;" isLeaf="true" n="Date"><div id="id2"><select name="name1" id="id3" style="display: none;"> 
<option value="38478">27-Mar-2014</option> 
<option value="38388">26-Mar-2014</option> 
</select></div></th> 

這是web ui中下拉菜單的代碼。我需要選擇2014年3月26日。我正在使用蟒蛇硒。從隱藏元素的下拉列表中選擇

我寫的代碼

driver.execute_script("document.getElementById('id3').style.display='block'") 

,但我得到JavaScript錯誤,當我運行的代碼。請告知我在這裏錯過了什麼。

+1

看一看:http://stackoverflow.com/questions/7340680/selenium-how-can-i-make-webdriver-ignore-element-is-not-visible-error – alecxe

回答

0

執行會導致顯示對象的動作(例如鼠標懸停事件)更爲明智。

使用JavaScript強制可見性並不能證明應用程序實際上適用於人類用戶,因此使測試無效。

我已經自動化了十年,只有一次當我沒有找到複製人類交互的方式時,我被迫注入JavaScript。

相關問題