예제 #1
0
        public void Test_OAuth()
        {
            var sessionId = 1;
              var redirectUrl = String.Format(_redirectUrlTemplate, _googleOAuthServer);
              var authUrl = _googleAuthUrl + "?" +
              StringHelper.FormatUri(_authUrlQueryTemplate, _clientId, redirectUrl, _scopes, sessionId);

              var browser = new BrowserHandler();
              browser.Open();
              browser.NavigateTo(authUrl);
              var doc = browser.GetDocument();
              Thread.Sleep(5000);
              var title = doc.Title;
              if (title.StartsWith("Sign in")) {
            var elEmail = doc.GetElementById("Email");
            elEmail.InnerText = _userGmail;
            var btnNext = doc.GetElementById("next");
            browser.Click(btnNext);
            doc = browser.GetDocument();
            var elPwd = doc.GetElementById("Passwd");
            elPwd.SetAttribute("value", _userGmailPwd);
            var btnSignin = doc.GetElementById("signIn");
            browser.Click(btnSignin);
              }
              doc = browser.GetDocument();
              var btnAllow = doc.GetElementById("submit_approve_access");
              browser.Click(btnAllow);
              Thread.Sleep(15000);
              browser.Close();
        }
예제 #2
0
        public void Test_OAuth()
        {
            var sessionId   = 1;
            var redirectUrl = String.Format(_redirectUrlTemplate, _googleOAuthServer);
            var authUrl     = _googleAuthUrl + "?" +
                              StringHelper.FormatUri(_authUrlQueryTemplate, _clientId, redirectUrl, _scopes, sessionId);

            var browser = new BrowserHandler();

            browser.Open();
            browser.NavigateTo(authUrl);
            var doc = browser.GetDocument();

            Thread.Sleep(5000);
            var title = doc.Title;

            if (title.StartsWith("Sign in"))
            {
                var elEmail = doc.GetElementById("Email");
                elEmail.InnerText = _userGmail;
                var btnNext = doc.GetElementById("next");
                browser.Click(btnNext);
                doc = browser.GetDocument();
                var elPwd = doc.GetElementById("Passwd");
                elPwd.SetAttribute("value", _userGmailPwd);
                var btnSignin = doc.GetElementById("signIn");
                browser.Click(btnSignin);
            }
            doc = browser.GetDocument();
            var btnAllow = doc.GetElementById("submit_approve_access");

            browser.Click(btnAllow);
            Thread.Sleep(15000);
            browser.Close();
        }