コード例 #1
0
ファイル: ElementHandler.cs プロジェクト: YangEricLiu/Mento
        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;
            }
        }
コード例 #2
0
        private static void ClickHttpsSecurityWarning()
        {
            string title = BrowserHandler.GetPageTitle();

            if (title.StartsWith("Certificate Error"))
            {
                BrowserHandler.Navigate("javascript:document.getElementById('overridelink').click()");
            }
        }
コード例 #3
0
        /// <summary>
        /// Open Jazz with special browser and maximize the window,OK
        /// </summary>
        /// <returns></returns>
        public static void OpenJazz()
        {
            BrowserHandler.Navigate(ExecutionContext.Url);

            if (ExecutionContext.Browser == Browser.IE)
            {
                ClickHttpsSecurityWarning();
            }
        }
コード例 #4
0
 public static string GetMainWindowHandle()
 {
     return(BrowserHandler.GetMainWindowHandle());
 }
コード例 #5
0
 public static void SwitchToWindowByHandle(string windowHandle)
 {
     BrowserHandler.switchToWindowByHandle(windowHandle);
 }
コード例 #6
0
 public static void CloseTheCurrentWidnow()
 {
     BrowserHandler.CloseTheCurrentWindow();
 }
コード例 #7
0
 public static void CloseTheWidnow(string windowTitle)
 {
     BrowserHandler.CloseTheWindow(windowTitle);
 }
コード例 #8
0
 //临时的
 public static void SwitchToEmptyWidnow()
 {
     BrowserHandler.switchToEmptyWindow();
 }
コード例 #9
0
 public static void SwitchToWidnow(string windowTitle)
 {
     BrowserHandler.switchToWindow(windowTitle);
 }
コード例 #10
0
 public static void RefreshJazz()
 {
     BrowserHandler.Refresh();
 }
コード例 #11
0
 /// <summary>
 /// Close the browser but NOT log out from Jazz
 /// </summary>
 /// <returns></returns>
 public static void CloseJazz()
 {
     BrowserHandler.Quit();
 }