Monday, 18 February 2013

Selenium does not close the Internet Explorer browser after selenium.stop(); method

Selenium with the combination of  windows 7, IE 9 . After executing selenium.stop(); method, ideally it should close test runner and AUT window.However it closes only test runner window and
app window remains open .



There is one work around for this issue :

1.  Save below vb script in a say "file.vbs"
set objService = getobject("winmgmts:")

for each Process in objService.InstancesOf("Win32_process")
 If Process.Name = "iexplore.exe" Then
Process.Terminate()
End If
Next


2. Execute above vb script by using following java code ; Put below line after calling selenium.stop() method.
   
    try {
            Runtime.getRuntime().exec("wscript D:\\script\\CloseBrowser.vbs ");
        } catch (IOException e) {
              e.printStackTrace();
        }




No comments:

Post a Comment