Login through portal and trying to load HTML
I have a C# program that logs into a portal, and then needs to test if an
element with a specific ID exists on the page or not. In order to test for
this, I grab the HTML from the page and search for an element with a
matching ID in the HTML.
However, whenever I try to access the HTML with this script, it always
returns the HTML of the portal login page, and not the page after one logs
in through the portal. I can confirm 100% that the program is logging into
the portal, however for some reason it is still returning the wrong HTML.
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
WebClient client = new WebClient();
string html = client.DownloadString(this.currentStepUrl);
doc.LoadHtml(html);
var foo = (from bar in doc.DocumentNode.DescendantNodes()
where bar.GetAttributeValue("id", null) == expected
select bar).FirstOrDefault();
if (foo != null)
{
currentTestCaseResults[0]++;
}
else
{
currentTestCaseResults[1]++;
}
No comments:
Post a Comment