Hi,
I have Automated the task till logging in External site. But after login, i need to perform some tasks like...selecting the menu options...clicking on Download links without any manual efforts..
Please Suggest me some code which detects the menu items,fetch the data from fields if any,clicks the links etc., and does the remaining tasks automatically.(Only Using MVC)
What I have tried:
string appURL = "http://localhost.com";
string strPostData = String.Format("userName={0}&password={1}",
"username", "password");
// Setup the http request.
HttpWebRequest wrWebRequest = WebRequest.Create(appURL) as
HttpWebRequest;
wrWebRequest.Method = "post";
wrWebRequest.ContentLength = strPostData.Length;
wrWebRequest.ContentType = "application/x-www-form-urlencoded";
CookieContainer cookieContainer = new CookieContainer();
wrWebRequest.CookieContainer = cookieContainer;
// Post to the login form.
StreamWriter swRequestWriter = new
StreamWriter(wrWebRequest.GetRequestStream());
swRequestWriter.Write(strPostData);
swRequestWriter.Close();
// Get the response.
HttpWebResponse hwrWebResponse = (HttpWebResponse)wrWebRequest.GetResponse();
// Read the response
StreamReader srResponseReader = new
StreamReader(hwrWebResponse.GetResponseStream());
string strResponseData = srResponseReader.ReadToEnd();
srResponseReader.Close();
Response.Write(strResponseData);
return cookieContainer;