做了大半个月的测试,总结下selenium使用注意实现
来源:互联网 发布:mac mini散热器 编辑:程序博客网 时间:2024/05/05 09:46
1.尽量不用send_key,使用js给input赋值。send_key有时不起作用
2.execute_script 获取值的脚本写法'var ret=$("div.datagrid-body > table > tbody > tr > td:nth-child(2) > div").text();return ret;'
3.每个case不退出浏览器,代码写法@classmethod
def setUpClass(cls):
cls.driver = webdriver.Chrome()
cls.driver.implicitly_wait(30)
cls.driver.maximize_window()
cls.base_url = "http://10.10.12.18"
@classmethoddef tearDownClass(cls):
cls.driver.close()
cls.driver.quit()
self.assertFalse(ret1 or ret2),这样htmlreport输出的结果为failed,一开始学习是我就使用raise
def init_log(report_dir):
logger = logging.getLogger('mylogger')
logger.setLevel(logging.INFO)
fh = logging.FileHandler('%s\\test.log' % report_dir)
fh.setLevel(logging.INFO)
ch = logging.StreamHandler(stream=HTMLTestRunner.stdout_redirector)
ch.setLevel(logging.INFO)
formatter = logging.Formatter('%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s')
fh.setFormatter(formatter)
ch.setFormatter(formatter)
logger.addHandler(fh)
logger.addHandler(ch)
return logger
def load_jquery(self):
with open('jquery-1.11.3.js', 'r') as jquery_js: # read the jquery from a file
jquery = jquery_js.read()
self.driver.execute_script(jquery) # active the jquery lib
8.运行所有test时,注意类的继承
文件base.py:
class Base(unittest.TestCase):
def test_xxx(self)
print "test"
文件test_service.py:
from base import Base
class Service(Base)
pass
在discover时会发现Base的test_xxx
def create_suite():
test_unit = unittest.TestSuite()
# discover 方法定义
discover = unittest.defaultTestLoader.discover(
test_lists,
pattern='test*.py',
top_level_dir=None)
# discover方法筛选出用例,循环添加到测试套件中
for test_suite in discover:
for test_case in test_suite:
test_unit.addTests(test_case)
return test_unit
正确的做法时
import base
class Service(base.Base)
0 0
- 做了大半个月的测试,总结下selenium使用注意实现
- 做了大半个月的测试,总结下selenium使用注意实现
- 有点烦恼,有点困惑:拖了大半个月,补偿的钱未到帐
- 开了一个月yunfile的会员,发现没东西可下,做了个软件分享下
- 使用Python+selenium实现第一个自动化测试脚本
- 逛个了大半个丰台~``
- Selenium WebDriver 与 iOS 自动化测试 (做了一些初步的工具对比)
- 大半年来做的计算这点事
- 最近做了个测试,是关于communication skills 的。
- 最近做了个测试:关于Inteview的
- 使用 Selenium 实现基于 Web 的自动化测试
- 使用 Selenium 实现基于 Web 的自动化测试
- 使用 Selenium 实现基于 Web 的自动化测试
- 使用 Selenium 实现基于 Web 的自动化测试
- 使用 Selenium 实现基于 Web 的自动化测试
- 使用Selenium实现基于Web的自动化测试
- AnsiString的索引从1开始,靠,害得我浪费了大半个小时
- 做兼职美工做了快3个月的经验总结
- 《疯狂Android讲义》 -- Android 动画系列之自定义补间动画(三维动画)
- sql 拼接 格式化日期 拼接原来字段
- 人头检测代码示例:SVM+HOG
- PHP:无限极分类
- mysql 字符集设置问题
- 做了大半个月的测试,总结下selenium使用注意实现
- ListView最基本的使用方法SimpleAdapter(二)
- Java:对象的强、软、弱和虚引用
- 各种破解的注册码
- freeswitch 解决方案之视频会议
- 16字节对齐
- 学习笔记之JavaSE(23)--多线程3
- Android:拖动退出界面
- LeetCode10. Regular Expression Matching