品易云推流 关闭
文章详情页
文章 > Python常见问题 > python3 selenium如何清空输入框中的内容

python3 selenium如何清空输入框中的内容

头像

silencement

2020-03-03 18:27:046070浏览 · 0收藏 · 0评论

使用场景:搜索的时候,我需要清除搜索框中其他的关键词

使用方法:driver.clear()

举例说明:

#  设定搜索内容
search_content = ['java', '测试']
# 定位搜索框的位置
search_key = self.driver.find_element_by_css_selector("input.search-key")
# 清空搜索框中的内容
search_key.clear()
# 搜索
search_key.send_keys(random.choice(self.search_content))

更多技术请关注Python视频教程

关注

关注公众号,随时随地在线学习

本教程部分素材来源于网络,版权问题联系站长!

底部广告图