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

  • 相关阅读:
    .NET程序运行原理及基本概念详解
    c# 操作Redis的五种基本类型总结
    手写MQ框架(一)-准备启程
    手写MVC框架(二)-代码实现和使用示例
    手写DAO框架(七)-如何保证连接可用
    spring cloud入门
    maven学习整理
    mybatis入门学习
    spring事务使用探究
    微内核OS学习
  • 原文地址:https://www.cnblogs.com/chercher/p/5695535.html
Copyright © 2011-2022 走看看