作者jn8029 (鲁)
看板Python
标题Re: [问题]Selenium用Select Class去选多重下拉选单
时间Tue Apr 11 12:28:09 2017
喔喔, 因为他是用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
1F:推 jacobcan118: 感谢. 可以了 还是必须找每一个的element去选 04/13 10:19