(六)selenium如何启动google chrome/firefox浏览器

1.下载chrome/firefox驱动,对应相应版本的浏览器

把下载的浏览器驱动放在python目录下之后(前提python目录是环境变量path下的,我们之前放的是c盘的根目录)

2.打开pycharm新建项目:

file--new project

3.新建python文件,右键工程新建:

4.工程下导入selenium

file--setting--project:WebAutoScript--project interpreter

5.编写脚本:

使用google chrome浏览器

from seleniumimport webdriver

driver=webdriver.Chrome()

driver.get('https://www.baidu.com')

driver.quit()

使用firefox浏览器:

from seleniumimport webdriver

driver=webdriver.Firefox()

driver.get('https://www.baidu.com')

driver.quit()

猜你喜欢

转载自www.cnblogs.com/wx921308494/p/11966646.html