Adding a cookie to a IE browser session
Posted: Sun Jul 27, 2014 7:01 pm
Hi ...
We are opening a IE browser session using processStartInfo. I would like to set a cookie in that session. What is the best way to do this. Can I add the cookie to the URL when I open the browser with processStartInfo --- or should I use HttpCookie ??
A code sample would be appreciated as I'm having some issues with using HttpCookie -- processStartInfo is working ...
Thanks,
Chris
We are opening a IE browser session using processStartInfo. I would like to set a cookie in that session. What is the best way to do this. Can I add the cookie to the URL when I open the browser with processStartInfo --- or should I use HttpCookie ??
A code sample would be appreciated as I'm having some issues with using HttpCookie -- processStartInfo is working ...
Thanks,
Chris
Code: Select all
public LaunchBrowser(){}
void ITestModule.Run()
{
uri = this.createURI();
Report.Info("URI: " + uri);
Report.Info("Launching Internet Explorer Maximized..");
ProcessStartInfo processStartInfo = new ProcessStartInfo(
@"C:\Program Files\Internet Explorer\iexplore.exe");
processStartInfo.WindowStyle = ProcessWindowStyle.Maximized;
processStartInfo.Arguments = uri;
SummaryBase.process = Process.Start(processStartInfo);
}
private String createURI()
{
String summaryURI = uri;
// Testing here
// How does this work ???
// return artifacts.ElementAt(randomNumber);
Report.Info("-----------------------------");
Report.Info("Inside createURI()");
Report.Info("ArtifactUuid: " + ArtifactUuid);
if (!UseJudicialSearch && (summaryURI != null))
{
if (summaryURI.Contains("?"))
{
summaryURI += "&searchuuid=" + ArtifactUuid;
}
else
{
summaryURI += "?searchuuid=" + ArtifactUuid;
}
}
Report.Info("summaryURI: " + summaryURI);
return summaryURI;
}
// We are going to set the cookie here and see what happens
// string url = "http://javascript:workbench.setCookie('mockFlagForTesting','true')";
// doc.Navigate(url, true, 10000);
HttpCookie myCookie = new HttpCookie("mockFlagForTesting");
// Set the cookie value.
myCookie.Value = "true";
// Add the cookie.
Response.Cookies.Add(myCookie);