selenium python bindings 项目结构总结

一个合理的文档结构在import的过程当中会避免不少错误,踩完坑来记录。python

webtests/

         framework.py

         webdriver.py

         test_file.py

         module/

                __init__.py

                PageObjects/
          
__init__.py
all_pages.py object.py

 

上面这个丑丑的就是修改完后比较合理正确的一个文档结构。web

说明:ui

1. 以test_开头命名全部的testcase文件this

 

2. 抽出公共的方法到framework中code

 

3. webdriver 中要声明执行的testcase的位置blog

 

4. module中的__init__.py 文件们。这些init文件有的是包含了你所要import的内容,有的只是空。这是出自python的定义,为了指示这是一个module,能够从这里面import你所须要的类,在module的各级目录里都添加了init的文件文档

The __init__.py files are required to make Python treat the directories as containing packages; this is done to prevent directories with a common name, such as string, from unintentionally hiding valid modules that occur later on the module search path. In the simplest case, __init__.py can just be an empty file, but it can also execute initialization code for the package or set the __all__ variable, described later. string

 

5. object.py中的内容是一个页面的页面元素抽象以及页面通用方法it

 

6. all_pages.py能够在framework中被import,这个文件中是import了全部的object.py文件中的类io

相关文章
相关标签/搜索