摘要:
pytest入门 一、安装pytest pip install pytest 二、运行pytest pytest [options] [file_or_dir] [file_or_dir] [...] 如果不提供任何参数,pytest会在当前目录以及子目录下寻找测试文件,然后运行测试用例,如果提供了 阅读全文
摘要:
setup和teardown pytest中有类似unittest中setUp,tearDown方法 一、运行级别 模块级 作用于一个模块内的所有class和def,对于所有class和def,setup和teardown只执行一次 setup_module teardown_module 类级 作 阅读全文
摘要:
命令行执行 目录结构 . ├── __init__,py ├── test_001.py └── test_002.py test_001.py #!/usr/bin/python3 #-*- conding:utf-8 -*- def test_one(): print('test_one') d 阅读全文
摘要:
截图 #!/usr/bin/python3 from selenium import webdriver import time chrome = webdriver.Chrome() chrome.maximize_window() chrome.get('https://www.baidu.co 阅读全文
摘要:
鼠标+键盘事件 一、鼠标事件 Selenium提供ActionChains类中 from selenium.webdriver.common.action_chains import ActionChains 鼠标操作的常用方法: 操作 方法 右击 context_click() 双击 double 阅读全文
摘要:
等待 等待主要存在三种形式,分别是固定等待,隐式等待,显示等待 一、固定等待 由python中的time模块提供,无论前面的代码是否执行完成或者还未完成,都必须等待设定的时间 time.sleep() 二、隐式等待 通过设定的时长等待页面元素加载完成,再执行下面的代码,如果超过设定时间还未加载完成, 阅读全文
摘要:
下拉框+弹窗处理 一、下拉框 针对下拉框,selenium提供了Select类来处理 from selenium.webdriver.support.select import Select 1、实例化下拉框 定位到下拉框 rp = chrome.find_element_by_name('rp') 阅读全文
摘要:
WebElement类的方法 1、清空(clear()) #!/usr/bin/python3 from selenium import webdriver import time chrome = webdriver.Chrome() chrome.get('https://www.baidu.c 阅读全文
摘要:
WebDriver浏览器的属性 1、获取url地址 #!/usr/bin/python3 from selenium import webdriver ~~~~ chrome = webdriver.Chrome() chrome.maximize_window() chrome.get('http 阅读全文
摘要:
iframe+windows切换 iframe切换 如果一个元素无法定位到,那么最大的可能时定位的元素属性在iframe框架中,iframe对象代表一个HTML的内联框架,在HTML中iframe每出现一次,一个iframe对象就被创建。 一、iframe切入 iframe存在id属性 例: #!/ 阅读全文