python+selenium 点击单选框-radio的实现方法
作者:ever_mwumli 时间:2023-07-11 01:51:54
例子:以百度文库中选择文档的类型为例
问题一:遍历点击所有文档类型的单选框
# coding=utf-8
from selenium import webdriver
from time import sleep
driver = webdriver.Chrome()
driver.maximize_window()
driver.get("http://wenku.baidu.com")
driver.implicitly_wait(8)
for i in driver.find_element_by_xpath("//*/input[@type='radio']"): # 实现遍历点击所有的radio
print(i)
sleep(3)
i.click()
sleep(3)
问题二:点击其中一种文档类型
# coding=utf-8
from selenium import webdriver
from time import sleep
driver = webdriver.Chrome()
driver.maximize_window()
driver.get("http://wenku.baidu.com")
driver.implicitly_wait(8)
driver.find_element_by_xpath("//*[@id='t_ppt']").click() # 实现点击PPT文档类型
sleep(3)
遗留问题:大家是否有方法,可以实现不定的点击切换radio,可在下面的评论中留下实现方法,谢谢啦!
来源:https://blog.csdn.net/ever_mwumli/article/details/77946158
标签:python,selenium,radio
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python常用的文件及文件路径、目录操作方法汇总介绍
2022-03-21 00:00:25
一文带你了解MySQL中触发器的操作
2024-01-13 13:22:11
![](https://img.aspxhome.com/file/2023/8/129938_0s.png)
Python实现统计文本文件字数的方法
2023-05-24 11:46:04
js实现页面图片消除效果
2024-04-28 10:20:54
将MySQL的临时目录建立在内存中的教程
2024-01-25 20:42:40
python实现多张图片拼接成大图
2021-11-19 08:36:53
![](https://img.aspxhome.com/file/2023/8/103268_0s.jpg)
Python的Flask框架中的Jinja2模板引擎学习教程
2022-05-28 10:26:08
Burpsuite入门及使用详细教程
2023-08-15 19:07:07
![](https://img.aspxhome.com/file/2023/9/99389_0s.png)
Python matplotlib以日期为x轴作图代码实例
2021-08-17 03:41:09
![](https://img.aspxhome.com/file/2023/9/109599_0s.jpg)
python3实现简单飞机大战
2022-11-11 02:27:18
![](https://img.aspxhome.com/file/2023/3/99173_0s.jpg)
javascript动态添加单元格的脚本代码
2023-09-02 05:21:26
MAC版修改MySQL初始密码的方法
2024-01-19 03:19:56
SQL字符串处理函数大全
2024-01-25 07:09:13
轻松接触MaxDB和MySQL之间的协同性
2008-11-27 16:25:00
Python中dict和set的用法讲解
2023-12-09 05:20:55
![](https://img.aspxhome.com/file/2023/7/81507_0s.png)
为SQL Server数据库传数组参数的变通办法
2009-10-23 09:26:00
MySQL创建表操作命令分享
2024-01-25 20:08:35
![](https://img.aspxhome.com/file/2023/3/76353_0s.png)
Python tkinter三种布局实例详解
2022-11-28 11:23:44
![](https://img.aspxhome.com/file/2023/7/86417_0s.jpg)
10个Python小技巧你值得拥有
2022-02-03 16:28:56
MySQL锁的知识点总结
2024-01-13 18:19:46