private async Task OnLogin(HtmlDocument doc) { if (!_canPerformLogin) { Log("cannot do `Login` action because document do not loaded yet"); return; } _canPerformLogin = false; Log("attemp to login"); SetStatus("attemp to login"); await Task.Delay(50); inputs = WebRequestHelper.GetFormInputs(doc.GetElementsByTagName("html")[0].InnerHtml, "frmLogin"); if (inputs.Count == 0) { Log("input fields not found"); return; } _code = inputs["txtCode"]; GetPassword(_code); return; if (doc == null) { Log("cannot get html document, action fail"); SetStatus("cannot get html document, action fail"); return; } Log("get document success, seting data up"); SetStatus("get document success, seting data up"); var userInput = doc.GetElementById("txtID"); var passInput = doc.GetElementById("txtPW"); if (userInput == null || passInput == null) { Log("input not found"); SetStatus("input not found"); return; } SetStatus("setting user account"); userInput.InnerText = "SSD020101001"; passInput.InnerText = "Qqqq1111"; var links = doc.GetElementsByTagName("a"); var count = links.Count; for (int i = 0; i < count; i++) { var inner = links[i].InnerHtml; if (!string.IsNullOrEmpty(inner) && inner.Equals("<span>Go</span>", StringComparison.OrdinalIgnoreCase)) { Log("found submit button, perform click action"); await Task.Run(() => { links[i].InvokeMember("click"); }); return; } } }