zoukankan      html  css  js  c++  java
  • java+Selenium+TestNg搭建自动化测试架构(1)实现代码和数据的分离

    1.主要介绍介绍Java+Selenium+POM的自动化测试框架的搭建,第一个首先实现代码和账号URL等信息的分离。第二点支持跨浏览器,通过读取配置文件的方式实现。

         1)将账号URL等信息添加在properties文件中然后读取

         2)编写浏览器类通过去取配置文件实现浏览器的切换

         3)测试浏览器类

    项目结构:

     

    1.新建一个文件夹将properties文件放在文件夹中内容如下:

    # browser switcher
    #browserName = Firefox
    browserName = Chrome
    #browserName = IE
    # test server switcher
    URL=https://portal.rrx360.com
    #URL=https://taobao.com

    2.写一个解析properties文件类的方法去读取文件获取需要的信息

    package com.rrx.framework;

    import java.io.FileInputStream;
    import java.io.IOException;
    import java.util.Properties;


    public class PropertiesEngine {
    public static String getProperties(String name) throws IOException {

    Properties properties=new Properties();
    properties.load(new FileInputStream(".\TestConfig\config.properties") );
    String zhi=properties.getProperty(name);

    return zhi;

    }
    }

  • 相关阅读:
    左孩子右兄弟的字典树
    UVA 1401 Remember the Word
    HDOJ 4770 Lights Against Dudely
    UvaLA 3938 "Ray, Pass me the dishes!"
    UVA
    Codeforces 215A A.Sereja and Coat Rack
    Codeforces 215B B.Sereja and Suffixes
    HDU 4788 Hard Disk Drive
    HDU 2095 find your present (2)
    图的连通性问题—学习笔记
  • 原文地址:https://www.cnblogs.com/liwei09k1/p/8109716.html
Copyright © 2011-2022 走看看