selenium如何启动google chrome/firefo

2019-08-12  本文已影响0人  偶然路过的靓仔_胡阳

1.把下载的浏览器驱动放在python目录下之后(前提python目录是环境变量path下的)

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()

上一篇 下一篇

猜你喜欢

热点阅读