Error while attempting to close IE browser
Posted: Thu Jan 03, 2019 10:38 am
Hello all,
I have a scenario in my test case where i'm supposed to close browsers and below is the code for reference and this code works great with chrome and firefox where as in IE I'm ending up with exception errors.
public void closeBrowsers()
{
try{
IList<Ranorex.WebDocument> browsers = Host.Local.FindChildren<Ranorex.WebDocument>();
for(int i=0; i<browsers.Count; i++)
{
browsers.Close();
Delay.Seconds(2);
Report.Info("Closing Browsers");
}
}
catch(RanorexException e){
Report.Info("Closing browsers exception caught:" +e);
}
}
Exception Error:
++++++++++++++++++
08:14.379 Info User
Closing Browsers
08:14.409 Info User
Jump to item
Closing browsers exception caught:Ranorex.ActionFailedException: Action 'close' failed on element '{WebDocument:IE}'. ---> System.Runtime.Remoting.RemotingException: Failed to write to an IPC Port: The pipe is being closed.
Server stack trace:
at System.Runtime.Remoting.Channels.Ipc.IpcPort.Write(Byte[] data, Int32 offset, Int32 size)
at System.Runtime.Remoting.Channels.Ipc.PipeStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at System.Runtime.Remoting.Channels.ChunkedMemoryStream.WriteTo(Stream stream)
at System.Runtime.Remoting.Channels.Ipc.IpcClientHandler.SendRequest(IMessage msg, ITransportHeaders headers, Stream contentStream)
at System.Runtime.Remoting.Channels.Ipc.IpcClientTransportSink.ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITransportHeaders& responseHeaders, Stream& responseStream)
at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Ranorex.Plugin.TridentIpc.ITridentDom.SetDocumentValue(IntPtr browserRef, String name, String val)
at Ranorex.Plugin.WebDocumentRemoteFlavorElement.InvokeAction(Element element, String name, Object[] args)
at Ranorex.Core.Element.InvokeAction(String name, Object[] args)
--- End of inner exception stack trace ---
at Ranorex.Core.Element.InvokeAction(String name, Object[] args)
at Ranorex.WebDocument.Close()
at Itte.CodeModules.Misc.Commonmethod.closeBrowsers() in c:\Users\jos.johnson\Documents\Ranorexstudioprojects\Itte\CodeModules\Misc\Commonmethod.cs:line 128
I have a scenario in my test case where i'm supposed to close browsers and below is the code for reference and this code works great with chrome and firefox where as in IE I'm ending up with exception errors.
public void closeBrowsers()
{
try{
IList<Ranorex.WebDocument> browsers = Host.Local.FindChildren<Ranorex.WebDocument>();
for(int i=0; i<browsers.Count; i++)
{
browsers.Close();
Delay.Seconds(2);
Report.Info("Closing Browsers");
}
}
catch(RanorexException e){
Report.Info("Closing browsers exception caught:" +e);
}
}
Exception Error:
++++++++++++++++++
08:14.379 Info User
Closing Browsers
08:14.409 Info User
Jump to item
Closing browsers exception caught:Ranorex.ActionFailedException: Action 'close' failed on element '{WebDocument:IE}'. ---> System.Runtime.Remoting.RemotingException: Failed to write to an IPC Port: The pipe is being closed.
Server stack trace:
at System.Runtime.Remoting.Channels.Ipc.IpcPort.Write(Byte[] data, Int32 offset, Int32 size)
at System.Runtime.Remoting.Channels.Ipc.PipeStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at System.Runtime.Remoting.Channels.ChunkedMemoryStream.WriteTo(Stream stream)
at System.Runtime.Remoting.Channels.Ipc.IpcClientHandler.SendRequest(IMessage msg, ITransportHeaders headers, Stream contentStream)
at System.Runtime.Remoting.Channels.Ipc.IpcClientTransportSink.ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITransportHeaders& responseHeaders, Stream& responseStream)
at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Ranorex.Plugin.TridentIpc.ITridentDom.SetDocumentValue(IntPtr browserRef, String name, String val)
at Ranorex.Plugin.WebDocumentRemoteFlavorElement.InvokeAction(Element element, String name, Object[] args)
at Ranorex.Core.Element.InvokeAction(String name, Object[] args)
--- End of inner exception stack trace ---
at Ranorex.Core.Element.InvokeAction(String name, Object[] args)
at Ranorex.WebDocument.Close()
at Itte.CodeModules.Misc.Commonmethod.closeBrowsers() in c:\Users\jos.johnson\Documents\Ranorexstudioprojects\Itte\CodeModules\Misc\Commonmethod.cs:line 128