webdriver结束进程
使用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;
 }