Exemplo n.º 1
0
        private void ExpandVolume(IWebBrowser webBrowser, string id)
        {
            string scriptCode = "var node = document.getElementById('" + id + "').click();";

            webBrowser.AddScriptMethod(scriptCode);
            Thread.Sleep(3000);
        }
Exemplo n.º 2
0
        private void Login()
        {
            string      pageUrl    = "https://www.linkedin.com";
            string      tabName    = "login";
            IWebBrowser webBrowser = this.RunPage.InvokeShowWebPage(pageUrl, tabName, WebBrowserType.Chromium, false);

            this.RunPage.ShowTabPage(tabName);
            string htmlContent = null;
            int    waitCount   = 0;
            int    timeout     = 30000;

            while (htmlContent == null)
            {
                if (SysConfig.WebPageRequestInterval * waitCount > timeout)
                {
                    //超时
                    throw new GrabRequestException("请求Logout页超时. PageUrl = " + pageUrl);
                }
                //等待
                waitCount++;
                Thread.Sleep(SysConfig.WebPageRequestInterval);
                htmlContent = webBrowser.GetDocumentText();
            }

            string[] userInfo = _UserInfoList[_CurrentUserIndex];

            string userName = userInfo[0].Trim();
            string password = userInfo[1].Trim();

            string inputUserInfoCode = "document.getElementById('login-email').click();document.getElementById('login-email').value = '" + userName + "';document.getElementById('login-password').click();document.getElementById('login-password').value = '" + password + "';document.getElementById('login-submit').disabled=false;";

            webBrowser.AddScriptMethod(inputUserInfoCode);
            Thread.Sleep(3000);

            string submitUserInfoCode = "document.getElementById('login-submit').click();";

            webBrowser.AddScriptMethod(submitUserInfoCode);
            Thread.Sleep(3000);
        }