I want to run a script using API calls in C#. I don't want the webpage to open and just the script should run. I am trying this:
HttpWebRequest request = WebRequest.Create(URL) as HttpWebRequest;
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
HtmlDocument doc; //I have tried HtmlDocument = new HtmlDocument();, didn't work.
var resultStream = response.GetResponseStream();
doc.LoadHtml(resultStream); // I have tried using Load instead of LoadHtml,didn't work out.
doc.InvokeScript("Submit");
I get an error, use of unassigned variable doc. and doc doesn't contain function name LoadHtml. I have adding the Microsoft.VisualStudio.TestTools.UITesting.HtmlControls;
, didn't help.
I have checked th questions HtmlDocument.LoadHtml from WebResponse? and Get HTML code from website in C# but they didn't get an error on doc.
Any solutions.