All Downloads are FREE. Search and download functionalities are using the official Maven repository.

holmos.webtest.constvalue.ConfigConstValue Maven / Gradle / Ivy

There is a newer version: 1.0.2u10
Show newest version
package holmos.webtest.constvalue;

import holmos.webtest.basetools.HolmosPropertiesTool;

import java.io.File;
import java.io.UnsupportedEncodingException;
import java.util.Properties;

/**
 * Holmos框架配置文件用到的常量,加载配置文件规则
* (1)优先级如下,如果C盘有holmosconf目录,则加载C盘下面的配置文件,其他地方的无效
* (2)如果C盘没有,则加载用户根目录下面的路径,这个方便大家在linux系统下面进行配置
* (3)如果用户根目录没有,则加载使用者工程所在根目录下的holmosconf目录下的配置文件
* (4)如使用者工程根目录也没有,则加载使用者maven工程的resources目录下的配置文件,注意这个时候分两种情况
*
  • 如果使用者是在src/main/java下些的代码,则需将holmosconf目录下的配置文件配置到src/main/resources
  • *
  • 如果使用者是在src/test/java下些的代码,则需将holmosconf目录下的配置文件配置到src/test/resources
  • * @author 吴银龙(15857164387) * */ public class ConfigConstValue { private static String CONFNAME="holmosconf"; private static String CONFDIR; public static String LOGCONFIG; public static String UPLOADFILE; public static String DOWNLOADFILE; public static String IEDRIVER; public static String CHROMEDRIVER; public static String CSSPROPERTIESCONFIG; public static String IMGCSSPROPERTIESCONFIG; public static String HOLMOSCONFFILE; private static void initResourcesConf(){ File conf=new File(ClassLoader.getSystemResource("").getPath().substring(1)+CONFNAME); if(conf.exists()&&conf.isDirectory()) CONFDIR=conf.getAbsolutePath(); } private static void initProjectBaseConf(){ File conf=new File(System.getProperty("user.dir")+"\\"+CONFNAME); if(conf.exists()&&conf.isDirectory()) CONFDIR=conf.getAbsolutePath(); } private static void initUserDirBaseConf(){ File conf=new File(System.getProperty("user.home")+"\\"+CONFNAME); if(conf.exists()&&conf.isDirectory()) CONFDIR=conf.getAbsolutePath(); } private static void initCConf(){ File conf=new File("C:\\"+CONFNAME); if(conf.exists()&&conf.isDirectory()) CONFDIR=conf.getAbsolutePath(); } private static void initHolmosConf(){ initResourcesConf(); initProjectBaseConf(); initUserDirBaseConf(); initCConf(); LOGCONFIG=CONFDIR+"\\log4j.properties"; UPLOADFILE=CONFDIR+"\\autoItScripts\\upload.exe"; DOWNLOADFILE=CONFDIR+"\\autoItScripts\\download.exe"; IEDRIVER=CONFDIR+"\\driverServers\\IEDriverServer.exe"; CHROMEDRIVER=CONFDIR+"\\driverServers\\chromedriver.exe"; CSSPROPERTIESCONFIG=CONFDIR+"\\cssProperties\\css_comman_property_config.properties"; IMGCSSPROPERTIESCONFIG=CONFDIR+"\\cssProperties\\css_img_property_config.properties"; HOLMOSCONFFILE=CONFDIR+"\\holmosConf.properties"; } static{ try { initHolmosConf(); HOLMOSCONFFILE = java.net.URLDecoder.decode(HOLMOSCONFFILE,"utf8"); LOGCONFIG=java.net.URLDecoder.decode(LOGCONFIG,"utf8"); UPLOADFILE=java.net.URLDecoder.decode(UPLOADFILE,"utf8"); DOWNLOADFILE=java.net.URLDecoder.decode(DOWNLOADFILE,"utf8"); IEDRIVER=java.net.URLDecoder.decode(IEDRIVER,"utf8"); CHROMEDRIVER=java.net.URLDecoder.decode(CHROMEDRIVER,"utf8"); CSSPROPERTIESCONFIG=java.net.URLDecoder.decode(CSSPROPERTIESCONFIG,"utf8"); IMGCSSPROPERTIESCONFIG=java.net.URLDecoder.decode(IMGCSSPROPERTIESCONFIG,"utf8"); System.setProperty("webdriver.ie.driver", IEDRIVER); System.setProperty("webdriver.chrome.driver", CHROMEDRIVER); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } /**默认等待一次的时间*/ public static int defaulwaitMiliSeconds=50; /**默认等待次数,默认等待一个元素加载5秒*/ public static int defaultWaitCount=1; /**等待加载次数,默认等待加载30s*/ public static int waitCount=600; /**默认等待页面加载时间,默认10s*/ public static int waitPageLoadTime=10000; static{ Properties properties=HolmosPropertiesTool.getPropertyInfo(HOLMOSCONFFILE); defaulwaitMiliSeconds=HolmosPropertiesTool.getInt(properties, "defaulwaitMiliSeconds"); defaultWaitCount=HolmosPropertiesTool.getInt(properties, "defaultWaitCount"); waitCount=HolmosPropertiesTool.getInt(properties, "waitCount"); waitPageLoadTime=HolmosPropertiesTool.getInt(properties, "waitPageLoadTime"); } /**用来指明Holmos框架的数据源路径前缀配置,是否要添加当前的测试类所在包的包路径*/ public static final String DATA_SOURCE_PACKAGE_PREFIX_USEABLE="Holmos.data.source.package.prefix.useable"; /**设定Holmos框架数据源路径的前缀,不设置或设置为"",则认为没有前缀,否则是有前缀的*/ public static final String DATA_SOURCE_PREFIX_VALUE="Holmos.data.source.prefix.value"; /**配置的所有的modules的关键字*/ public static final String HOLMOS_MODULES="holmos.modules"; /**单个module的引用关键字*/ public static final String HOLMOS_MODULE="holmos.module"; /**指示单个module是否被激活的key*/ public static final String ENABLED=".enable"; /**Holmos框架HolmosModule类实现的类路径*/ public static final String HOLMOS_MODULE_CLASS_PATH="Holmos.Holmos.testlistener.modules.imp."; /**autoIt3x.dll文件地址*/ public static String AUTOITDLLPATH; }




    © 2015 - 2024 Weber Informatics LLC | Privacy Policy