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文件中的类

  • 相关阅读:
    centos 系统时间设置
    centos6 centos7 配置开机启动服务
    centos6.9 samba配置
    vmware异常关闭后导致虚拟机无法打开问题解决办法
    try using -rpath or -rpath-link
    ZR#988
    提高十连测day3
    Atcoder ABC 141
    ZR#957
    ST表
  • 原文地址:https://www.cnblogs.com/chercher/p/5695535.html
Copyright © 2011-2022 走看看