Skip to content

Commit 7da7b11

Browse files
author
LaoBian
committed
案例三:python selenium使用
1 parent 322f27a commit 7da7b11

File tree

3 files changed

+88
-18
lines changed

3 files changed

+88
-18
lines changed

.idea/workspace.xml

Lines changed: 70 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
python案例分享
33

44
案例一:python循环实现gitlab狐狸头图标
5-
案例二:python unittest使用
5+
案例二:python unittest使用
6+
案例二:python selenium使用

selenium使用.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from selenium import webdriver
2+
3+
#实例化一个浏览器驱动
4+
chrome = webdriver.Chrome()
5+
6+
#访问页面
7+
chrome.get("https://www.baidu.com/")
8+
#捕获元素
9+
inputs = chrome.find_element_by_id("kw")
10+
#对元素进行操作
11+
inputs.send_keys("老边饺子")
12+
button = chrome.find_element_by_id("su")
13+
button.click()
14+
#关闭浏览器
15+
chrome.close()
16+

0 commit comments

Comments
 (0)