标签:baidu attribute code value select elf sele div ret
1 url="https://www.baidu.com" 2 driver = webdriver.Chrome() 3 driver.get(url) 4 xpath="" #Select元素的Xpath串 5 ele_sel = driver.find_element_by_xpath(xpath) #获取Select元素对像 6 select_value = ele_sel.get_attribute(‘value‘) #获取Select选中的值 7 obj_select = Select(self.CurrentEle) #强制类型转换为Select类型 8 #遍历Select列表所有选项,根据值反求出选中的文本值 9 for optio in obj_select.options: 10 if(str(optio.get_attribute(‘value‘))==str(select_value)): 11 result["text"]=str(optio.text) 12 result["val"]=select_value 13 #返回结果 14 return result
Enjoy :)
标签:baidu attribute code value select elf sele div ret
原文地址:https://www.cnblogs.com/want990/p/13391428.html