private static HtmlDocument EnterCredentialsAndSignIn(BrowserWindow browser, HtmlDocument page, string login, string password) { // Check if there is a login user chooser (some identity already logged-in) HtmlControl loginUserChooser = new HtmlControl(page); loginUserChooser.SearchProperties[HtmlEdit.PropertyNames.Id] = "login_user_chooser"; loginUserChooser.TryFind(); if (loginUserChooser.Exists) { HtmlTable chooseAnotherAccount = new HtmlTable(loginUserChooser); chooseAnotherAccount.SearchProperties[HtmlTable.PropertyNames.Id] = "use_another_account"; chooseAnotherAccount.TryFind(); if (chooseAnotherAccount.Exists) { Mouse.Click(chooseAnotherAccount); } } // Enter the login and password HtmlEdit loginTextBox = new HtmlEdit(page); loginTextBox.SearchProperties[HtmlEdit.PropertyNames.Id] = "cred_userid_inputtext"; loginTextBox.Text = login; loginTextBox.WaitForControlReady(); // The page can be refreshed. page = new HtmlDocument(browser); HtmlEdit passwordTextBox = new HtmlEdit(page); passwordTextBox.SearchProperties[HtmlEdit.PropertyNames.Id] = "cred_password_inputtext"; passwordTextBox.EnsureClickable(); passwordTextBox.Password = password; HtmlControl signInButton = new HtmlControl(page); signInButton.SearchProperties[HtmlControl.PropertyNames.Id] = "cred_sign_in_button"; Mouse.Click(signInButton); // Get the new page page = new HtmlDocument(browser); return(page); }