杨钦元 博客

Selenium 面向页面(page object)

面向页面编写测试用例的好处 减少重复代码。 如果页面变动,只需更改少部分代码,可维护性强。 适合团队协作。 来自官网的例子: 1. Test.case import unittest from selenium import webdriver import page class PythonOrgSearch(unittest.TestCase): """A sample test class to show how page object works""" def setUp(self): self.driver = webdriver.Firefox() # 创建 Firefox 的实例 self.drive... Read more

python 操作文件和目录

>>>os.path.abspath('.') '/www' >>>os.path.join('/www','testdir') /www/testdir >>>os.path.mkdir('/www/testdir') >>>os.path.rmdir('/www/testdir') >>>os.path.split('/www/testdir/file.txt') ('www/testdir','file.txt') >>>os.path.splitext('/www/testdir/file.txt') # 获取文件扩展名 ('/www/testdir/file','.tx... Read more

python 文档测试

doctest 模块按照交互模式自动执行注释内容,以此测试测程序 class Dict(dict): ''' >>> d1 = Dict() >>> d1.y = 200 >>> d1['y'] 200 >>> d2 = Dict(a=1, b=2, c='3') >>> d2.c '3' ''' def __init__(self, **kw): super(Dict, self).__init__(**kw) def __getattr__(self, key): try:... Read more

jupyter FAQ

Q1:忘记密码 jupyter notebook password Q2: Page not found pip install --upgrade jupyter Read more

python class 详解

限制访问属性 实例的变量名如果以__开头,就变成了一个私有变量(private),只有内部可以访问,外部不能访问 class MyObject(object): def __init__(self, name, score): self.__name = name self.__name = score 操作对象信息 几个方法:dir(), hasattr(),setattr(),getattr(),isinstance() dir("abc") # 列出str类所有的方法属性 hasattr(MyObjcet,name) # 返回True or Not getattr(MyObject,name,400)# 如果没有则返回 default(400) s... Read more