How to InvokeMember using HtmlAgilityPack

c# html-agility-pack login

Question

I want to employHtmlAgilityPack log in to class. But I have no idea how.

I have tried this. But it doesn't function.

txtUserName.Text = "username";
txtPassword.Text = "password";
HtmlAgilityPack.HtmlDocument doc = new HtmlWeb().Load("about:Tabs");
doc.GetElementbyId("username").SetAttributeValue("value", txtUserName.Text);
doc.GetElementbyId("password").SetAttributeValue("value", txtPassword.Text);
foreach (HtmlNode node in doc.DocumentNode.SelectNodes("//button[@class='btn login-btn blue pull-right btn-primary']"))
 {
    node[0].InvokeMember("click");//wrong code
 }

I use zzz-18 zzzWebBrowser class.

1
1
12/13/2015 7:28:14 PM

Accepted Answer

I discovered how to log in usingSelenium I believe it's the best approach, too:

IWebDriver driver = new FirefoxDriver();
driver.Navigate().GoToUrl("Your Address Login");
IWebElement query = driver.FindElement(By.Id("username"));
query.SendKeys("Your Username");
query = driver.FindElement(By.Id("password"));
query.SendKeys("Your Password");
query.Submit();

the dotnet selenium download

Afterwards, add a referenceWebDriver.dll also employ namespaceOpenQA.Selenium.Firefox;

Find out more zzz-30 zzz

2
12/13/2015 7:47:01 PM

Popular Answer

Only html can be parsed by HtmlAgilityPack.

Instead, use WebClient.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow