如果需要定位一组对象,需要使用以下方法,会返回一个list
- find_elements_by_name
- find_elements_by_xpath
- find_elements_by_link_text
- find_elements_by_partial_link_text
- find_elements_by_tag_name
- find_elements_by_class_name
- find_elements_by_css_selector
element = driver.find_element_by_xpath("//select[@name=‘name‘]") all_options = element.find_elements_by_tag_name("option") for option in all_options: print("Value is: %s" % option.get_attribute("value")) option.click()
4. 定位一组对象
时间: 2024-10-07 16:31:07