Re: [問題]Selenium用Select Class去選多重下拉選單
不行. 可以選到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")
: ※ 引述《jacobcan118 (jacobcan118)》之銘言:
: : 請問我用python連selenium去做網頁multiple select 想選A, B C值. 但我用下面三種選的方法都可以選到或打開
: : div的tag看到option. 但在select的變數裡. o.text都是空字串. 我用select.select_by_value("A"),
: : select.select_by_options 都無法選到option. 但是把len(select.options) print出來長度是對的
: : 請問我要怎麼用selenium "Select" class去選那些option?
: : select = Select(driver.find_element_by_xpath('//*[@id="selectName"'))
: : driver.find_element_by_xpath("//*[@id="selectedRoles"]/select")
: : driver.find_element_by_name("selectName")
: : print(select.options)
: : print([o.text for o in select.options])
: : print(len(select.options))
: : return len(select.options)
: : <div id = "selectName" role = "listbox" >
: : <select type = "hidden" name = "selectName" multiple = "" >
: : <option value = "" > < / option >
: : <option value = "A" > A < /option >
: : <option value = "B" > B < /option >
: : <option value = "C" > C < /option >
: : < / select >
: : < / div >
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 108.14.0.213
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1491849017.A.56A.html
→
04/11 08:42, , 1F
04/11 08:42, 1F
→
04/11 10:20, , 2F
04/11 10:20, 2F
→
04/11 10:21, , 3F
04/11 10:21, 3F
→
04/11 10:23, , 4F
04/11 10:23, 4F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 3 之 4 篇):