zoukankan      html  css  js  c++  java
  • selenium python bindings 项目结构总结

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

    webtests/
    
             framework.py
    
             webdriver.py
    
             test_file.py
    
             module/
    
                    __init__.py
    
                    PageObjects/
              
    __init__.py
    all_pages.py object.py

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

    说明:

    1. 以test_开头命名所有的testcase文件

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

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

    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.

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

    6. all_pages.py可以在framework中被import,这个文件中是import了所有的object.py文件中的类

  • 相关阅读:
    js闭包
    python切片 []取值操作符
    python with语句
    python鸭子类型(duck type)
    python编码规范
    python @property使用详解
    python __slots__使用详解
    Python面向对象编程
    ifconfig命令详解
    5、Cocos2dx 3.0游戏开发找小三之測试例子简单介绍及小结
  • 原文地址:https://www.cnblogs.com/chercher/p/5695535.html
Copyright © 2011-2022 走看看