예제 #1
0
        public string WaitForVisibilityOfURL(string url)
        {
            try
            {
                WebDriverWait wait       = new WebDriverWait(driver, TimeSpan.FromSeconds(GetWaitTimeoutSeconds()));
                string        actual_url = wait.Until(CustomExpectedConditions.urlContainedBy(url));

                string info = string.Format("Wait for URL [{0}] displays", url);
                NLogger.Info(info);
                HtmlReporter.Pass(info);

                return(actual_url);
            }
            catch (WebDriverTimeoutException ex)
            {
                var    message    = string.Format("The URL [{0}] is not presented as expected", url);
                string screenshot = ScreenShotCapturing.TakeScreenShoot(driver, message);
                HtmlReporter.Fail(message, ex, screenshot);
                throw new ErrorHandler(message, ex);
            }
        }
예제 #2
0
        public List <string> WaitForVisibilityOfAllElementTextsLocatedBy(string elementName, By byObject, List <string> itemList)
        {
            try
            {
                WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(GetWaitTimeoutSeconds()));
                List <string> list = wait.Until(CustomExpectedConditions.VisibilityOfAllElementTextsLocatedBy(byObject, itemList));

                string info = string.Format("Wait for text list to be present in element. String list: [{0}]; Element information: {1}",
                                            string.Join(", ", itemList.ToArray()), elementName);
                HtmlReporter.Pass(info);
                NLogger.Info(info);

                return(list);
            }
            catch (WebDriverTimeoutException ex)
            {
                var message = string.Format("Text list is not present in element as expected. String list: [{0}]; Element information: {1}",
                                            string.Join(", ", itemList.ToArray()), elementName);
                string screenshot = ScreenShotCapturing.TakeScreenShoot(driver, message);
                HtmlReporter.Fail(message, ex, screenshot);
                throw new ErrorHandler(message, ex);
            }
        }