zoukankan      html  css  js  c++  java
  • Selenium+Python的环境配置

    因为项目的原因,最近较多的使用了UFT来进行自动化测试工作,半年没有使用Selenium了,于是在自己的电脑上重新配置了基于python3.x的selenium环境,配置过程大致如下:

    1. Selenium安装

    Selenium在python下的环境配置相对简单,只需在python中安装selenium的包即可。

    2. Webdriver安装

    但对于针对不同浏览器的webdriver还需单独安装。

    之前在使用python2时,并没有对firefox浏览器安装单独的driver,但这次发现对于firefox,同样需要安装第三方驱动:geckodriver

    否则报错为:

    selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH. 

    Exception AttributeError: "'Service' object has no attribute 'process'"

    下载驱动(http://docs.seleniumhq.org/download/)后,将该驱动解压,并放置在firefox的目录下,随后将该路径添加至系统环境变量path,重启python环境,即可完成webdriver安装

    3. 其他浏览器

    对于ChromeDriver,安装过程大致类似,不再赘述

    安装完成后,可以简单地使用以下代码来测试安装效果:

    1 from selenium import webdriver
    2 
    3 driver = webdriver.Firefox()
    4 driver.get(“http://www.cnblogs.com/persistz/") #URL
  • 相关阅读:
    子矩阵
    [Ahoi2008]Meet 紧急集合
    立体图
    CF933B A Determined Cleanup
    CF746G New Roads
    树的重量
    CF519E A and B and Lecture Rooms
    矩阵
    深入浅出乘法逆元
    20180519模拟赛T2——pretty
  • 原文地址:https://www.cnblogs.com/persistz/p/6031691.html
Copyright © 2011-2022 走看看