惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

IT之家
IT之家
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
A
About on SuperTechFans
博客园 - 聂微东
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
B
Blog RSS Feed
U
Unit 42
Stack Overflow Blog
Stack Overflow Blog
Recent Announcements
Recent Announcements
雷峰网
雷峰网
罗磊的独立博客
Microsoft Security Blog
Microsoft Security Blog
Hugging Face - Blog
Hugging Face - Blog
L
LangChain Blog
人人都是产品经理
人人都是产品经理
The GitHub Blog
The GitHub Blog
F
Fortinet All Blogs
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Help Net Security
P
Proofpoint News Feed
The Cloudflare Blog
D
Docker
大猫的无限游戏
大猫的无限游戏

博客园 - bigdog

安装PyTorch_1 Pandas上的Dataframe求差集 Linux 下安装NLTK的过程 Python函数返回多结果 Pandas下的Dataframe如何实现多条件筛选 将英文缩写扩展成正常英文的方法 如何安装pytorch 安装MxNet Docker 的日常 Ubuntu上安装Docker Ubuntu华为云挂载新硬盘 Python读写大文件-将整行文字根据分号分行 Pandas中的DataFrame读取Mysql的方法 Pandas中的DataFrame读取Oracle的方法 Kettle 7.1 配置连接Oracle、Mysql、SqlServe的DLL文件准备 Nginx开启访问日志记录 Selenium chromeDriver 下载地址 在Linux上部署Nginx,反向代理tornado的WebSite Linux上安装Mysql
Selenium 获取Select元素的选中值
bigdog · 2020-07-28 · via 博客园 - bigdog
 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 :)

posted @ 2020-07-28 15:37  bigdog  阅读(3144)  评论()    收藏  举报