Watir关闭所有IE窗口的3种方法

1. 循环

def close_all_windows
  loop do
    begin
      Watir::IE.attach(:title, //).close
    rescue Watir::Exception::NoMatchingWindowFoundException
      break
    rescue
      retry
    end
  end
end

 

2. 调用waitr API

require 'watir/close_all'
Watir::IE.close_all

 

3. 结束进程

system("taskkill /t /f /im iexplore.exe")
 

你可能感兴趣的:(watir)