美文网首页测试日常我爱编程
(二)Python+ Selenium自动化测试入门打开三大浏览

(二)Python+ Selenium自动化测试入门打开三大浏览

作者: 八月未央2015 | 来源:发表于2018-05-14 20:22 被阅读23次

Firefox浏览器

  • 把firefox浏览器的安装目录拷贝到python安装目录下。
  • 最新版的firefox浏览器需要下载驱动,geckodriver,下载好之后把geckodriver复制到python安装目录下。
    下载地址:https://github.com/mozilla/geckodriver/releases/

Google 浏览器

Internet Explore 浏览器

注意:下载解压后,将chromedriver.exe , geckodriver.exe , Iedriver.exe发到Python的安装目录,例如 D:\python 。 然后再将Python的安装目录添加到系统环境变量的Path下面。

然后打开Python IDLE分别输入以下代码来启动不同的浏览器

启动谷歌浏览器

from selenium import webdriver

browser = webdriver.Chrome()
browser.get('http://www.baidu.com/')



启动火狐浏览器
from selenium import webdriver

browser = webdriver.Firefox()
browser.get('http://www.baidu.com/')


启动IE浏览器
from selenium import webdriver

browser = webdriver.Ie()
browser.get('http://www.baidu.com/')

相关文章

网友评论

    本文标题:(二)Python+ Selenium自动化测试入门打开三大浏览

    本文链接:https://www.haomeiwen.com/subject/jftsdftx.html