python+selenium浏览器调用(chrome、ie、firefox)

#coding=utf-8


from selenium import webdriver

driver=webdriver.Chrome()  #调用chrome浏览器

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

print driver.title

driver.quit()


------------------------------------------------------------------------------
如果调用其他浏览器,代码换下即可:

driver=webdriver.Ie()   #调用ie浏览器

driver=webdriver.Firefox()  #调用firefox浏览器

  

1 在chrome 下运行脚本,需要将chromedriver.exe 放在chrome浏览器安装目录下

(同时设置用户环境变量path:C:UsersxxxxxxAppDataLocalGoogleChromeApplication;)

2 在ie 下运行脚本,需要将IEDriverServer.exe 放在ie浏览器安装目录下

(同时设置用户环境变量path:C:Program FilesInternet Explorer )

3 在firefox下运行脚本,直接调用(默认安装路径下)

总结:调用chrome、ie浏览器需要提前把对应的driver下载好,并放到安装目录下,同时设置好环境变量

不断的总结,才能不断的提高;不断的思考,才能不断的进步!
原文地址:https://www.cnblogs.com/hyh123/p/7618314.html