I have a Selenium test that should download a file and check if it contains something. The test run ok in Firefox and Chrome but in IE 11 I get an exception.
IE driver: IEDriverServer version 2.41.0.0
The code :
<code>
var driver = new InternetExplorerDriver();
//....navigate and login to a page
var el = driver.FindElements(By.PartialLinkText("Download File"))
.First(p => p.GetAttribute("href").Contains("/downloadmyfile"));
var link = el.GetAttribute("href");
var client = new WebClient();
client.Headers[HttpRequestHeader.Cookie] = CookieString();
var data = client.DownloadString(new Uri(link));
</code>
The code to copy the cookies:
<code>
public string CookieString()
{
var cookies = driver.Manage().Cookies.AllCookies;
return string.Join("; ", cookies.Select(c => string.Format("{0}={1}", c.Name, c.Value)));
}
</code>
The exception :
- Message: The underlying connection was closed: An unexpected error occurred on a receive.
- InnerException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
The driver.Manage().Cookies.AllCookies for Firefox driver looks:
ASP.NET_SessionId=sesionId222222; .authcookie=xxxxxxxx; __utma=1.559549671.1404381398.1404381398.1404381398.1; __utmb=1.1.10.1404381398; __utmc=1; __utmz=1.1404381398.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); testingSite=culture=en
The driver.Manage().Cookies.AllCookies for IE driver looks:
__utma=1.342629986.1404310901.1404378456.1404381205.3; __utmb=1.2.10.1404381205; __utmc=1; __utmz=1.1404310901.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); testingSite=culture=en
For the same web page the browser cookie for IE browser has sessionId and .authcookie.
Anyone has a clue on what can go wrong with IE driver?
I see that the IE driver doesn't contain the cookies value for _SessionId and .authcookie There is a way to get the missing cookies for IE driver?
InnerException StackTrace :
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count) at System.Net.Security._SslStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32
count, AsyncProtocolRequest asyncRequest) at System.Net.Security._SslStream.StartReading(Byte[] buffer, Int32 offset, Int32
count, AsyncProtocolRequest asyncRequest) at System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) at System.Net.TlsStream.Read(Byte[] buffer, Int32 offset, Int32 size) at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size) at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)- Exception StackTrace :
-at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request) at System.Net.WebClient.DownloadString(Uri address) at MyClasss........