コード例 #1
0
ファイル: LiveLoginPage.cs プロジェクト: rikrak/NRewardBot
        public LiveLoginPage ProcessLogin(ICredentials credentials)
        {
            this.WithUsername(credentials.Username)
            .PressNext();

            var authStrategy = GetAuthMechanism();

            if (authStrategy == AuthenticationMechanism.Password)
            {
                this.WithPassword(credentials.Password)
                .PressSubmit()
                //.DoMultiFactorAuth()
                .PressStayLoggedIn();
                this.CheckForPasswordError();
            }

            if (authStrategy == AuthenticationMechanism.AuthenticatorApp)
            {
                // do what?
                var timeout = TimeSpan.FromMinutes(20);
                // wait until the auth app page is no longer displayed
                this.Driver.WaitUntil(d =>
                {
                    try
                    {
                        var _ = d.FindElement(By.Id(AuthAppId));
                        Log.Debug("Auth App page is still displayed");
                    }
                    catch (StaleElementReferenceException)
                    {
                        Log.Debug("Auth App page is no longer displayed");
                        return(true);
                    }
                    catch (NoSuchElementException)
                    {
                        Log.Debug("Auth App page is no longer displayed");
                        return(true);
                    }

                    return(false);
                }, throwOnTimeout: false, timeout: timeout);
            }

            if (authStrategy == AuthenticationMechanism.Undefined)
            {
                throw new Exception("Could not determine the authentication mechanism");
            }

            return(this);
        }
コード例 #2
0
 public RewardScenario(WebDriverFactory driverFactory, ICredentials credentials)
 {
     _driverFactory = driverFactory ?? throw new ArgumentNullException(nameof(driverFactory));
     _credentials   = credentials ?? throw new ArgumentNullException(nameof(credentials));
 }