作者jacobcan118 (jacobcan118)
看板Python
标题Re: [问题]Selenium用Select Class去选多重下拉选单
时间Tue Apr 11 02:30:16 2017
不行. 可以选到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://webptt.com/cn.aspx?n=bbs/Python/M.1491849017.A.56A.html
1F:→ jn8029: 有网址吗? 我刚随便用另一个网页这样做可以选到耶 04/11 08:42
3F:→ jacobcan118: 点像link里的multiselect 有input栏位,点选後选单会 04/11 10:21
4F:→ jacobcan118: 出现,但是我的option分别包在select 和另一个div里 04/11 10:23