public static void DoLoginMethod(IRunWebPage runPage, IWebBrowser wb, string loginName, string loginPassword) { string scriptMethodCode = "function myDoLogin(loginName, loginPassword){" + "document.getElementById('session_key-login').value = loginName;" + "document.getElementById('session_password-login').value = loginPassword;" + "document.getElementById('btn-primary').click();" + "}"; runPage.InvokeAddScriptMethod(wb, scriptMethodCode); runPage.InvokeDoScriptMethod(wb, "myDoLogin", new object[] { loginName, loginPassword }); }
private static void DoLogoutMethod(IRunWebPage runPage, IWebBrowser wb, string logoutSucceedCheckUrl, int timeout) { string scriptMethodCode = "function myGetLogoutPageUrl(){" + "var logoutElements = $('.account-submenu-split-link');" + "return (logoutElements.length == 0) ? 'http://www.linkedin.com/logout' : $(logoutElements[0]).attr('href');" + "}"; runPage.InvokeAddScriptMethod(wb, scriptMethodCode); string logoutPageUrl = (string)runPage.InvokeDoScriptMethod(wb, "myGetLogoutPageUrl", null); if (logoutPageUrl != null && logoutPageUrl.Length != 0) { runPage.ShowWebPage(logoutPageUrl, "logout", timeout, false, WebBrowserType.Chromium); } }