【发布时间】:2020-09-29 06:14:53
【问题描述】:
我有三个带有 id 的复选框
id = ["inputListings_I","inputListings_A","inputListings_B"]
我的问题:使用循环,我想一次选中一个复选框并取消选择另一个。假设我选择 id[0] 然后循环选择 id[1] 但它应该取消选中 id[0],如果循环选择 id[2] 它应该取消选中 id[1]。
怎么做?
lst = ["inputListings_I","inputListings_A","inputListings_B"]
for i in lst:
mm = driver.find_element_by_id(i)
if (mm.is_selected()):
js = f"document.getElementById({i}).click()"
driver.execute_script(js)
js = f"document.getElementById('{i}').click()"
driver.execute_script(js)"
"""unselect other two"""
【问题讨论】:
标签: javascript python for-loop selenium-chromedriver