随笔分类 -  Selenium(Python3)

摘要:1、显式等待 from selenium import webdriverfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.w 阅读全文
posted @ 2018-03-14 22:07 此生不换Yang 阅读(4449) 评论(0) 推荐(1) 编辑
摘要:整个工程的目录结构: 常用方法类: 阅读全文
posted @ 2018-03-04 17:21 此生不换Yang 阅读(825) 评论(0) 推荐(0) 编辑
摘要:使用PageObject页面对象的好处是, 当页面元素的位置发生改变时, 只需要去修改Xpath或者ID, 而不用去修改测试用例本身; 本次的思路是: 1、常用方法类 2、页面对象类 3、测试用例类 WebDriverMethod.py: BaiduHome.py: BaiduTest.py: 阅读全文
posted @ 2018-03-03 22:36 此生不换Yang 阅读(2583) 评论(1) 推荐(2) 编辑
摘要:import unittestfrom time import sleepfrom ddt import ddt, datafrom pymysql import connectfrom selenium import webdriverdef getMySQLTestData(): # 查询数据库 阅读全文
posted @ 2018-03-01 22:22 此生不换Yang 阅读(853) 评论(0) 推荐(1) 编辑
摘要:首先, 引入xlrd模块: ExcelDDT.py: 阅读全文
posted @ 2018-03-01 16:28 此生不换Yang 阅读(1543) 评论(0) 推荐(0) 编辑
摘要:import csvimport unittestfrom time import sleepfrom ddt import ddt, data, unpackfrom selenium import webdriverdef getCsvData(): # 读取CSV文件 value_rows = [] with open('./CsvTestData.csv', encodi... 阅读全文
posted @ 2018-02-28 13:02 此生不换Yang 阅读(2209) 评论(0) 推荐(0) 编辑
摘要:首先, 添加ddt模块: 阅读全文
posted @ 2018-02-28 10:48 此生不换Yang 阅读(472) 评论(0) 推荐(0) 编辑
摘要:首先, 添加PyMySQL模块: 代码: 阅读全文
posted @ 2018-02-27 20:18 此生不换Yang 阅读(445) 评论(0) 推荐(0) 编辑
摘要:1、通过示例介绍Selenium-WebDriver 一个简单的入门方法就是这个例子,它在Google上搜索术语“Cheese”,然后将结果页面的标题输出到控制台。java csharp pythonfrom selenium import webdriverfrom selenium.common 阅读全文
posted @ 2018-02-26 23:10 此生不换Yang 阅读(413) 评论(0) 推荐(0) 编辑
摘要:import osimport unittestdirectory = os.getcwd()# 测试用例的目录organize = unittest.defaultTestLoader.discover(directory, pattern='test*.py')"""discover()方法有3 阅读全文
posted @ 2018-02-26 12:31 此生不换Yang 阅读(804) 评论(0) 推荐(0) 编辑
摘要:"""A TestRunner for use with the Python unit testing framework. Itgenerates a HTML report to show the result at a glance.The simplest way to use this 阅读全文
posted @ 2018-02-25 21:41 此生不换Yang 阅读(501) 评论(0) 推荐(0) 编辑
摘要:import unittestfrom time import sleepimport osfrom selenium import webdriverimport win32apiimport win32conimport win32clipboard as cutfrom selenium.we 阅读全文
posted @ 2018-02-25 20:10 此生不换Yang 阅读(1675) 评论(0) 推荐(1) 编辑
摘要:假如你安装的是Python3.6, 那么可以直接用PyCharm或者pip安装pywin32模块: 但是, 由于我安装的是Python3.7, 所以PyCharm或者pip都无法成功安装pywin32模块, 所以只能手动安装了, 打开https://github.com/mhammond/pywin 阅读全文
posted @ 2018-02-25 15:05 此生不换Yang 阅读(46780) 评论(1) 推荐(2) 编辑
摘要:由于Python3已经不支持HTMLTestRunner了, 无论是PyCharm还是pip都无法安装成功, 所以只能去 http://tungwaiyip.info/software/HTMLTestRunner_0_8_2/HTMLTestRunner.py 手动下载: 在网页空白处点击鼠标右键 阅读全文
posted @ 2018-02-24 23:53 此生不换Yang 阅读(5310) 评论(0) 推荐(0) 编辑
摘要:unittest是Python的单元测试框架, 类似于Java里面的TestNG。 Unittest.py: 阅读全文
posted @ 2018-02-24 10:52 此生不换Yang 阅读(446) 评论(0) 推荐(0) 编辑
摘要:在浏览器地址栏输入https://www.seleniumhq.org/ 打开Selenium官网 下载Firefox浏览器驱动 解压到本地 下载Chrome浏览器驱动 解压到本地 把这2个驱动放到Python的安装目录下 阅读全文
posted @ 2018-02-24 10:29 此生不换Yang 阅读(535) 评论(0) 推荐(0) 编辑
摘要:Chrome浏览器与chromedriver.exe驱动可以是官网上最新的, 随意! Chrome.py: 阅读全文
posted @ 2018-02-24 10:02 此生不换Yang 阅读(555) 评论(0) 推荐(0) 编辑
摘要:我的版本是Firefox Setup 52.7.0.exe+geckodriver-v0.15.0-win64.zip, 把驱动geckodriver.exe放到Python安装目录下, 也可以指定驱动的路径; 请注意浏览器的版本与驱动的版本一定要对应, 否则会出现启动了浏览器却无法打开网址的异常! 阅读全文
posted @ 2018-02-24 09:46 此生不换Yang 阅读(4296) 评论(0) 推荐(0) 编辑
摘要:PyCharm添加Selenium与Appium依赖, 不需要用pip去安装! 阅读全文
posted @ 2018-02-23 22:51 此生不换Yang 阅读(6786) 评论(0) 推荐(0) 编辑
摘要:在地址栏输入http://www.jetbrains.com/pycharm/ 打开PyCharm官网 http://idea.lanyus.com/ 阅读全文
posted @ 2018-02-23 22:30 此生不换Yang 阅读(254) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示