Re: [問題]Selenium用Select Class去選多重下拉選單

看板Python作者 (魯)時間8年前發表 (2017/04/11 04:28), 8年前編輯推噓1(100)
留言1則, 1人參與, 最新討論串4/4 (看更多)
喔喔, 因為他是用ReactJS寫的 所以他不是用傳統HTML的Select啊 而且ReactJS的互動性會讓那個多選擇選單的html位置動來動去 你可以觀察到在點一個選項後(例如先點"Vanilla") 選單裡的選項順序會變 而且整個選單的html位置也會變 所以在選完一個選項後要再抓一次選單element 詳情請見我粗略寫的gist.. https://gist.github.com/et265831/3e57340366f9b44a73435c61e643d211 ※ 引述《jacobcan118 (jacobcan118)》之銘言: : 不行. 可以選到element但是select.options的值還是空的. 用select.select_by_value("A")會有 : selenium.common.exceptions.ElementNotVisibleException: Message: element not visible: Element is not currently visible and may not be manipulated : 錯誤 : ※ 引述《jn8029 (魯)》之銘言: : : 你的select變數選到的是<div id = "selectName">不是<select name="selectName">吧? : : 用以下這樣可行嗎? : : select = Select(driver.find_element_by_name("selectName")) : : select.select_by_value("A") ※ 編輯: jn8029 (175.182.110.158), 04/11/2017 12:35:32 ※ 編輯: jn8029 (175.182.110.158), 04/11/2017 12:37:32

04/13 10:19, , 1F
感謝. 可以了 還是必須找每一個的element去選
04/13 10:19, 1F
文章代碼(AID): #1Ox5jTVi (Python)
文章代碼(AID): #1Ox5jTVi (Python)