zoukankan      html  css  js  c++  java
  • webdriver结束进程

    欢迎光临娇娇家的美衣阁 http://shop105984718.taobao.com/

    使用webdriver做UI自动化测试,driver.quit();方法貌似没能起作用,执行完成后,还是一堆页面和进程在。

    所以就只能简单粗暴地杀进程了

     public void stop(){
      
      driver.quit();
      String name = null;
      try {
       name = getValue("driverName");
      } catch (IOException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
      }
      if(name.equals("ie")){
       WindowsUtils.tryToKillByName("IEDriverServer.exe");
      }else if(name.equals("chrome")){
       WindowsUtils.tryToKillByName("chromedriver.exe");
      }  
     }

    顺便说一下:name是从properties文件读取出来的,下面是读取properties文件内容的方法

     public String getValue(String key) throws IOException{
      if(key == null || key.isEmpty() || key.equals("")){
       return null;
      }
      return getFile(propertiesFileName).getProperty(key);  
     }

     public Properties getFile(String fileName) throws IOException{  
      InputStream in = this.getClass().getClassLoader().getResourceAsStream(fileName);
      AssertJUnit.assertTrue ("in为空", in != null);
       Properties p = new Properties();
       p.load(in);
       return p;
     }

    欢迎光临娇娇家的美衣阁 http://shop105984718.taobao.com/

  • 相关阅读:
    map
    构造函数和对象
    for...in...and for each...in...
    事件
    JSON
    css伪类
    正则表达式
    什么是DOM、什么是BOM
    CSS颜色
    grid-layout实验
  • 原文地址:https://www.cnblogs.com/joewu/p/3699585.html
Copyright © 2011-2022 走看看