Esempio n. 1
0
        public bool waitForElementIsPresent(string sName, string sType, string sObjectLocator, int iTimeOut)
        {
            try
            {
                WebDriverWait wait = new WebDriverWait(getDriver, TimeSpan.FromSeconds(iTimeOut));
                switch (sType)
                {
                case "id":
                    wait.Until(ExpectedConditions.ElementIsVisible((By.Id(sObjectLocator))));
                    ExReports.reportInfo("Element '" + sName + "' is found");
                    return(true);

                case "name":
                    wait.Until(ExpectedConditions.ElementIsVisible((By.Name(sObjectLocator))));
                    ExReports.reportPass("Element '" + sName + "' is found");
                    return(true);

                case "xpath":
                    wait.Until(ExpectedConditions.ElementIsVisible((By.XPath(sObjectLocator))));
                    ExReports.reportPass("Element '" + sName + "' is found");
                    return(true);

                case "link":
                    wait.Until(ExpectedConditions.ElementIsVisible(By.LinkText(sObjectLocator)));
                    ExReports.reportPass("Element '" + sName + "' is found");
                    return(true);
                }
                return(false);
            }
            catch (WebDriverTimeoutException)
            {
                ExReports.reportFail("Timeout is over - Element '" + sName + "' is not found");
                throw;
            }
        }
Esempio n. 2
0
 /// <Wait methods>
 public void waitForElementIsPresent(string sName, int iTimeOut, string sObjectLocator)
 {
     try
     {
         WebDriverWait wait = new WebDriverWait(getDriver, TimeSpan.FromSeconds(iTimeOut));
         wait.Until(ExpectedConditions.ElementIsVisible((By.Id(sObjectLocator))));
         ExReports.reportInfo("Element '" + sName + "' is found");
     } catch (WebDriverTimeoutException)
     {
         ExReports.reportFail("Timeout is over - Element '" + sName + "' is not found");
         throw;
     }
 }
Esempio n. 3
0
 public void checkMessage(string sType, string sObjectLocator, string sMessage)
 {
     try
     {
         switch (sType)
         {
         case "id":
             waitForElementIsPresent(sMessage, Constants.TIME_OUT, sObjectLocator);
             Assert.AreEqual(getDriver.FindElement(By.Id(sObjectLocator)).Text, sMessage);
             ExReports.reportInfo("Message '" + sMessage + "' is checked");
             break;
         }
     }
     catch (AssertFailedException e)
     {
         ExReports.reportFail("Message '" + sMessage + "' is not checked. " + e.Message);
         throw;
     }
 }
Esempio n. 4
0
 public void TearDown()
 {
     ExReports.reportInfo("Test was finished");
 }