示例#1
0
        public static void AlertAuthintications(IWebDriver webDriver, string _username, string _password)
        {
            WebDriverWait wait  = new WebDriverWait(webDriver, TimeSpan.FromSeconds(30));
            IAlert        alert = wait.Until(x => webDriver.SwitchTo().Alert());

            alert.SetAuthenticationCredentials(_username, _password);
        }
示例#2
0
        //Methods
        public static void Login(string user, string pwd)
        {
            IAlert alert = driver.SwitchTo().Alert();

            alert.SetAuthenticationCredentials(user, pwd);
            driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(30);
            alert.Accept();
        }
示例#3
0
        }//end method Common Setup

        public void WindowsLogin()
        {
            IAlert alert = _driver.SwitchTo().Alert();

            alert.SetAuthenticationCredentials(TestConfigs.userID, TestConfigs.password);
            _driver.SwitchTo().Alert().Accept();
            _driver.SwitchTo().DefaultContent();
        }
示例#4
0
        public void ShouldBeAbleToHandleAuthenticationDialog()
        {
            driver.Url = authenticationPage;
            IAlert alert = WaitFor <IAlert>(AlertToBePresent, "No alert found");

            alert.SetAuthenticationCredentials("test", "test");
            alert.Accept();
            Assert.That(driver.FindElement(By.TagName("h1")).Text, Does.Contain("authorized"));
        }
示例#5
0
        public void DoLogin(string username, string password)
        {
            // *** if the login authentication page hit
            // *** then login using username/password details ...

            IAlert alert = null;

            if (((alert = GetAlertFromLoginAuthenticationPage()) != null))
            {
                alert.SetAuthenticationCredentials(username, password);
                alert.Accept();
            }
        }
示例#6
0
 public static bool Authenticate(string username, string password)
 {
     try
     {
         IAlert alert = Driver.SwitchTo().Alert();
         alert.SetAuthenticationCredentials(username, password);
         return(WaitPageReady(30 * 1000));
     }
     catch (Exception ex)
     {
         return(true);
     }
 }
 /// <summary>
 /// Handles the Windows Security authentication popup
 /// Supported from Selenium 3.0
 /// </summary>
 /// <param name="username">The user name e.g domain\\username</param>
 /// <param name="password">The user password</param>
 public void Authenticate(string username, string password)
 {
     try
     {
         IAlert alert = driver.SwitchTo().Alert();
         alert.SetAuthenticationCredentials(username, password);
         alert.Accept();
     }
     catch (Exception ex)
     {
         reportsLibrary.WriteErrorMessageWithScreenshot(reportTypes, "fail", "Some error while authenticate with user: "******". <br><b>ErrorMessage: </b><br>" + ex.Message);
     }
 }
示例#8
0
 /// <summary>
 /// Check a Alert with sign in
 /// </summary>
 public static void signIncheckAlert()
 {
     try
     {
         WebDriverWait wait = new WebDriverWait(webDriver, TimeSpan.FromSeconds(30));
         wait.Until(ExpectedConditions.AlertIsPresent());
         IAlert alert    = webDriver.SwitchTo().Alert();
         string username = ConfigurationManager.AppSettings["UserName"];
         string password = ConfigurationManager.AppSettings["Password"];
         alert.SetAuthenticationCredentials(username, password);
         alert.Accept();
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
示例#9
0
        public void ShouldThrowAuthenticatingOnStandardAlert()
        {
            driver.Url = alertsPage;
            driver.FindElement(By.Id("alert")).Click();
            IAlert alert = WaitFor <IAlert>(AlertToBePresent, "No alert found");

            try
            {
                alert.SetAuthenticationCredentials("test", "test");
                Assert.Fail("Should not be able to Authenticate");
            }
            catch (UnhandledAlertException)
            {
                // this is an expected exception
            }

            // but the next call should be good.
            alert.Dismiss();
        }
示例#10
0
 public void PassAuthenticationIE(string login, string pass)
 {
     try
     {
         TimeSpan pageTimeout = GetPageTimeoutSpan();
         if (pageTimeout < TimeSpan.FromSeconds(5))
         {
             pageTimeout = TimeSpan.FromSeconds(5);
         }
         while (true)
         {
             WebDriverWait wait  = new WebDriverWait(this.Driver, pageTimeout);
             IAlert        alert = wait.Until(ExpectedConditions.AlertIsPresent());
             alert.SetAuthenticationCredentials(login, pass);
             alert.Accept();
             System.Threading.Thread.Sleep(100);
         }
     }
     catch (NoAlertPresentException) { }
     catch (WebDriverTimeoutException) { }
 }
示例#11
0
 public void SetAuthenticationCredentials(string userName, string password)
 {
     _alert.SetAuthenticationCredentials(userName, password);
 }