public Messages.BaseResult ExecuteTest(OpenQA.Selenium.IWebDriver driverToTest, Parser.TestItem itemToTest)
 {
     BaseResult br = new BaseResult();
     try
     {
         SeleniumHtmlHelper helper = new SeleniumHtmlHelper(driverToTest);
         if (helper.IsAlertPresent())
         {
             string alertText = helper.GrabTextFromAlertAndClose(acceptAlert: true);
             Assert.AreEqual(itemToTest.Selector, alertText);
         }
         else
         {
             throw new Exception("Alert not present");
         }
         br.Status = true;
         br.Message = "OK";
     }
     catch (Exception e)
     {
     #if DEBUG
         throw;
     #endif
         br.Status = false;
         br.Message = string.Format("Exception type: {0}. Message: {1}.", e.GetType(), e.Message);
     }
     return br;
 }
Beispiel #2
0
 public Messages.BaseResult ExecuteTest(OpenQA.Selenium.IWebDriver driverToTest, Parser.TestItem itemToTest)
 {
     BaseResult br = new BaseResult();
     try
     {
         SeleniumHtmlHelper helper = new SeleniumHtmlHelper(browserDriver: driverToTest);
         helper.ElementLocator(itemToTest.Selector).Click();
         br.Status = true;
         br.Message = "OK";
     }
     catch (Exception e)
     {
     #if DEBUG
         throw;
     #endif
         br.Status = false;
         br.Message = string.Format("Exception type: {0}. Message: {1}.", e.GetType(), e.Message);
     }
     return br;
 }
Beispiel #3
0
 public Messages.BaseResult ExecuteTest(OpenQA.Selenium.IWebDriver driverToTest, Parser.TestItem itemToTest)
 {
     BaseResult br = new BaseResult();
     try
     {
         double pauseLenghtMs = double.Parse(itemToTest.Value);
         System.Threading.Thread.Sleep(TimeSpan.FromMilliseconds(pauseLenghtMs));
         br.Status = true;
         br.Message = "OK";
     }
     catch (Exception e)
     {
     #if DEBUG
         throw;
     #endif
         br.Status = false;
         br.Message = string.Format("Exception type: {0}. Message: {1}.", e.GetType(), e.Message);
     }
     return br;
 }
        public Messages.BaseResult ExecuteTest(OpenQA.Selenium.IWebDriver driverToTest, Parser.TestItem itemToTest)
        {
            BaseResult br = new BaseResult();
            try
            {
                Assert.AreEqual(itemToTest.Selector, driverToTest.Title);

                br.Status = true;
                br.Message = "OK";
            }
            catch (Exception e)
            {
            #if DEBUG
                throw;
            #endif
                br.Status = false;
                br.Message = string.Format("Exception type: {0}. Message: {1}.", e.GetType(), e.Message);
            }
            return br;
        }
Beispiel #5
0
        public Messages.BaseResult ExecuteTest(OpenQA.Selenium.IWebDriver driverToTest, Parser.TestItem itemToTest)
        {
            BaseResult br = new BaseResult();
            try
            {
                SelectElement selectList;
                IWebElement element;
                SeleniumHtmlHelper helper = new SeleniumHtmlHelper(browserDriver: driverToTest);
                element = helper.ElementLocator(itemToTest.Selector);
                selectList = new SelectElement(element);
                if (itemToTest.Value.StartsWith("label="))
                {
                    selectList.SelectByText(itemToTest.Value.Replace("label=", ""));
                }
                else if (itemToTest.Value.StartsWith("value="))
                {
                    selectList.SelectByValue(itemToTest.Value.Replace("value=", ""));
                }
                else if (itemToTest.Value.StartsWith("id="))
                {
                    element.FindElement(By.XPath(string.Format(@"option[@id='{0}']", itemToTest.Value.Replace("id=", ""))));
                }
                else if (itemToTest.Value.StartsWith("index="))
                {
                    int index = int.Parse(itemToTest.Value.Replace("index=", ""));
                    selectList.SelectByIndex(index);
                }

                br.Status = true;
                br.Message = "OK";
            }
            catch (Exception e)
            {
            #if DEBUG
                throw;
            #endif
                br.Status = false;
                br.Message = string.Format("Exception type: {0}. Message: {1}.", e.GetType(), e.Message);
            }
            return br;
        }
Beispiel #6
0
 public Messages.BaseResult ExecuteTest(OpenQA.Selenium.IWebDriver driverToTest, Parser.TestItem itemToTest)
 {
     BaseResult br = new BaseResult();
     try
     {
         string domainUrl = new Uri(driverToTest.Url).GetLeftPart(UriPartial.Authority);
         // TODO: Modify passing of the base url? Is it really necessary? Input parameter?
         driverToTest.Navigate().GoToUrl(domainUrl + itemToTest.Selector);
         br.Status = true;
         br.Message = "OK";
     }
     catch (Exception e)
     {
     #if DEBUG
         throw;
     #endif
         br.Status = false;
         br.Message = string.Format("Exception type: {0}. Message: {1}.", e.GetType(), e.Message);
     }
     return br;
 }
 public Messages.BaseResult ExecuteTest(OpenQA.Selenium.IWebDriver driverToTest, Parser.TestItem itemToTest)
 {
     BaseResult br = new BaseResult();
     try
     {
         WebDriverWait waitLock = new WebDriverWait(driverToTest, TimeSpan.FromSeconds(Defaults.TIMEOUT_IN_SECONDS));
         SeleniumHtmlHelper helper = new SeleniumHtmlHelper(driverToTest);
         IWebElement element = waitLock.Until<IWebElement>((x) =>
             {
                 return helper.ElementLocator(itemToTest.Selector);
             });
         br.Status = true;
         br.Message = "OK";
     }
     catch (Exception e)
     {
     #if DEBUG
         throw;
     #endif
         br.Status = false;
         br.Message = string.Format("Exception type: {0}. Message: {1}.", e.GetType(), e.Message);
     }
     return br;
 }