Ejemplo n.º 1
0
        public static IWebElement FindElement(Locator locator, ISearchContext container = null)
        {
            if (container == null)
            {
                container = DriverFactory.Instance;
            }

            try
            {
                return(container.FindElement(locator.ToBy()));
            }
            catch (NoSuchElementException ex)
            {
                //capture error image
                string fileName = TestContext.CurrentContext.Test.FullName.GetHashCode() + ".jpg";

                string ImageFilePath = Path.Combine(NUnit.Framework.TestContext.CurrentContext.WorkDirectory, fileName);
                BrowserHandler.TakeCapture(ImageFilePath);

                //AppLog.Instance.LogInformation("Image: " + ImageFilePath);
                //AppLog.Instance.LogError(ex.ToString());

                throw new ApiException(String.Format("Can not found element with locator {0}", locator.ToString()), ex);
                //throw ex;
            }
        }