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

  • 相关阅读:
    Oracle学习(十四):管理用户安全性
    Android在发送带有附件的邮件
    Naive Bayes Classification
    java大全经典的书面采访
    安卓实现实时视频传输
    TCP:三次握手,URG、ACK、PSH、RST、SYN、FIN 含义
    SYN(synchronous)TCP/IP
    面向对象、面向过程与哲学
    面向过程和面向对象的哲学基础
    面向过程
  • 原文地址:https://www.cnblogs.com/chercher/p/5695535.html
Copyright © 2011-2022 走看看