第二十三节 selenium安装和入门

 1 from selenium import webdriver
 2 from selenium.webdriver.chrome.options import Options
 3 
 4 
 5 '''
 6 selenium :自动化测试工具,本身不是测试工具,只是模拟浏览器操作的工具
 7 webdriver:网页内驱动软件
 8 chrome:在浏览器中,是指浏览器的框架
 9 options:可选择的事物; 选择; 选择权
10     def __init__(self):
11         # 设置 chrome 二进制文件位置
12         self._binary_location = ''
13         # 添加启动参数
14         self._arguments = []
15         # 添加扩展应用
16         self._extension_files = []
17         self._extensions = []
18         # 添加实验性质的设置参数
19         self._experimental_options = {}
20         # 设置调试器地址
21         self._debugger_address = None
22 '''
23 import time
24 
25 
26 __browser_url = r'C:\Users\Administrator\AppData\Local\360Chrome\Chrome\Application\360chrome.exe' #浏览器目录地址
27 chrome_options = Options()  #定义一个浏览器内核选择对象
28 chrome_options.binary_location = __browser_url  # 设置 chrome 二进制文件位置
29 brower = webdriver.Chrome(options=chrome_options)
30 
31 brower.get("http://www.baidu.com")
32 print(brower.page_source)
33 
34 
35 # time.sleep(3)
36 # brower.close()

 

posted @ 2020-03-16 21:49  kog_maw  阅读(115)  评论(0编辑  收藏  举报