0
我做了一个登录按钮,并要检查,如果用户登录或没有。我通过两种方式来做到这一点。获取当前的web浏览器的URL或web浏览器的内容
- 检查的web浏览器的URL是一个URL相等(如果用户成功登录的网址是URL1,如果没有该URL URL2)
- 检查当前的web浏览器的内容所包含的单词(例如,如果用户登录成功,然后在重定向的页面都应该有“谢谢”的字样)
我想提一提,所有的工作我唯一的问题是,以检查他是否登录或不
public void Login()
{
webBrowser1.Document.GetElementById("username").SetAttribute("value", txtUsername.Text);
webBrowser1.Document.GetElementById("password").SetAttribute("value", txtPassword.Text);
foreach (HtmlElement item in webBrowser1.Document.GetElementsByTagName("input"))
{
if (item.OuterHtml.Contains("input_submit"))
{
item.InvokeMember("Click");
break; // Here the webbrowser redirect right?
}
}
if (webBrowser1.Document.Body.InnerText.Contains("Thank you"))
con = true;
else
con = false;
}