一、以搭建windows平台为例

准备工具如下:
1)下载Python
2)安装,配置环境变量
3)安装selenium,通过pip安装,命令如下:
 pip install selenium
方式二:直接下载selenium包,解压,然后执行python setup.py install
4)安装webdriver(以IE driver为例):
下载解压后,会有一个 iedriver.exe文件,需要将此文件放到IE浏览器的安装目录下。
二、环境搭建好了后,写个简单的自动化脚本验证一下(以12306购票为例:)
三、相关问题解决
1)定位弹出型元素方法:先用F12打开调试,选择要定位的元素--》console--》输入setTimeOut(funcation(){debugger;},5000)--》执行--》页面会停住--》然后再定位弹出框中的元素
2)对于随机产生的id元素进行定位:
往上看父节点找id,根据父节点id来定位子元素,具体如下:
driver.find_element_by_css_selector(父元素id>li:first-child/nth-child(index))
验证方式一:Ctrl+f 输入-》显示高亮
方式二:console $$("父元素id>li:first-child/nth-child(index) ")
3)对于没有id的,定位方式选择CSS选择器:
定位元素-》鼠标右击-》选择copy-》copy selector

selenium+python 搭建自动化环境的更多相关文章

  1. (selenium+python)_UI自动化01_Mac下selenium环境搭建

    前言 Selenium 是一个用于Web网页UI自动化测试的开源框架,可以驱动浏览器模拟用户操作.支持多种平台(Windows.Mac OS.Linux)和多种浏览器(IE.Firefox.Chrom ...

  2. selenium + python + firefox 测试环境的搭建与配置

    对于做UI自动化,如果是纯编写一段自动化测试程序,那么后续的维护成本会较高.这种情况下,借助 selenium 这款自动化系测试工具,辅助于自己编写部分脚本,将是个不错的选择.selenium 本身支 ...

  3. selenium+python在mac环境上的搭建

    前言 mac自带了python2.7的环境,所以在mac上安装selenium环境是非常简单的,输入2个指令就能安装好 需要安装的软件: 1.pip 2.selenium2.53.6 3.Firefo ...

  4. selenium+python实现自动化登录

    工作需要实现一个微博自动登录的操作,在网上差了一些资料,决定使用selenium+python实现 selenium 是一个web的自动化测试工具,主流一般配合java或者python使用,我这里使用 ...

  5. Selenium+Python系列 - 开发环境搭建

    一.写在前面 我从未想过自己会写python系列的自动化文章,有些同学会问,那你现在为什么又开始写了? 不止一个人找过我,问我可以写一些Python自动化的文章吗,答案是肯定的. 笔者Java党,整P ...

  6. Python+Appium自动化环境搭建

    appium工作原理 appium 在android端工作流 client端也就是我们 test script是我们的webdriver测试脚本. 中间是起的Appium的服务,Appium在服务端起 ...

  7. selenium+python在mac环境上的搭建【转载】

    前言 mac自带了python2.7的环境,所以在mac上安装selenium环境是非常简单的,输入2个指令就能安装好 需要安装的软件: 1.pip 2.selenium2.53.6 3.Firefo ...

  8. selenium +python web自动化测试环境搭建

    基础框架搭建 1.安装python 2.安装selenium cmd输入pip install selenium 问题:在python中输入from selenium import webdriver ...

  9. Selenium+Python的开发环境搭建

    第一步:安装Python  https://www.python.org/ 注意:在cmd窗口中输入python,如果不是内部或者外部命令的需要配置环境变量Path ; 右击桌面我的电脑-->属 ...

随机推荐

  1. Elasticsearch + Elasticsearch-head搭建

    Elasticsearch搭建: [root@hdoop3 elk]# tar -xvf elasticsearch-6.2.4.tar [root@hdoop3 elk]# cd elasticse ...

  2. AFSoundManager

    iOS audio playing (both local and streaming) and recording made easy through a complete and block-dr ...

  3. 修改系统UITableViewCell的ImageView大小

    代码如下: CGSize itemSize = CGSizeMake(, ); UIGraphicsBeginImageContext(itemSize); CGRect imageRect = CG ...

  4. JAVA中基本类型和字符串之间的转换

    一.基本类型转换成字符串有三种方法: int c = 10; 1.使用包转类的toString()方法 String str1 = Integer.toString(c); 2.使用String类的v ...

  5. ABAP术语-URL

    URL 原文:http://www.cnblogs.com/qiangsheng/archive/2008/03/20/1114193.html Uniform Resource Locator (U ...

  6. python3>日期和时间

    阅读目录 1.python3日期和时间 2.时间元组 3.获取格式化的时间 4.格式化日期 5.获取月日历 6.Time模块 7.datetime模块 回到顶部 1.python3日期和时间 Pyth ...

  7. Linux查看当前登录用户并踢出用户

    1.查看当前登录用户 [wilsh@lcl ~]$ whatis w w                    (1)  - Show who is logged on and what they a ...

  8. attr 和 prop的区别

    attr 返回的是字符串 prop 返回的是布尔值

  9. 重写UICollectionViewFlowLayout报cache mismatched frame警告

    在重写UICollectionViewFlowLayout的时候会有很多坑,比如: Logging only once for UICollectionViewFlowLayout cache mis ...

  10. Delphi Firemonkey在主线程 异步调用函数(延迟调用)

    先看下面的FMX.Layouts.pas中一段代码 procedure TCustomScrollBox.MouseDown(Button: TMouseButton; Shift: TShiftSt ...