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; } }
private static void ClickHttpsSecurityWarning() { string title = BrowserHandler.GetPageTitle(); if (title.StartsWith("Certificate Error")) { BrowserHandler.Navigate("javascript:document.getElementById('overridelink').click()"); } }
/// <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(); } }
public static string GetMainWindowHandle() { return(BrowserHandler.GetMainWindowHandle()); }
public static void SwitchToWindowByHandle(string windowHandle) { BrowserHandler.switchToWindowByHandle(windowHandle); }
public static void CloseTheCurrentWidnow() { BrowserHandler.CloseTheCurrentWindow(); }
public static void CloseTheWidnow(string windowTitle) { BrowserHandler.CloseTheWindow(windowTitle); }
//临时的 public static void SwitchToEmptyWidnow() { BrowserHandler.switchToEmptyWindow(); }
public static void SwitchToWidnow(string windowTitle) { BrowserHandler.switchToWindow(windowTitle); }
public static void RefreshJazz() { BrowserHandler.Refresh(); }
/// <summary> /// Close the browser but NOT log out from Jazz /// </summary> /// <returns></returns> public static void CloseJazz() { BrowserHandler.Quit(); }