//Perform text check ocr function with boolean return public static bool OCRTextCheckPoint(out long uxTime, RemoteWebDriver driver, String text, int threshold, int timeout, bool reportTimer = false, String timerDescription = "timer description", string timerName = "timer name") { bool checkpointPassed; Console.WriteLine("Find: " + text); string command = "mobile:checkpoint:text"; Dictionary <string, object> Parameters = new Dictionary <string, object>(); Parameters.Add("content", text); Parameters.Add("timeout", timeout.ToString()); Parameters.Add("measurement", "accurate"); Parameters.Add("source", "camera"); Parameters.Add("analysis", "full"); if (threshold > 0) { Parameters.Add("threshold", threshold.ToString()); } string findstring = (string)driver.ExecuteScript(command, Parameters); bool.TryParse(findstring, out checkpointPassed); uxTime = GetUXTimer(driver); if (reportTimer) { WindTunnelUtils.ReportTimer(driver, uxTime, timeout * 1000, timerDescription, timerName); } Console.WriteLine("report timer: " + timerName + " value: " + uxTime.ToString() + " threshold: " + (timeout * 1000).ToString()); return(checkpointPassed); }
//Performs image click ocr function public static long OCRImageCheck(RemoteWebDriver driver, String img, int threshold, int timeout, bool reportTimer = false, String timerDescription = "timer description", string timerName = "timer name") { Console.WriteLine("Find: " + img); string command = "mobile:checkpoint:image"; Dictionary <string, object> Parameters = new Dictionary <string, object>(); Parameters.Add("content", img); Parameters.Add("timeout", timeout.ToString()); Parameters.Add("measurement", "accurate"); Parameters.Add("source", "camera"); Parameters.Add("analysis", "automatic"); if (threshold > 0) { Parameters.Add("threshold", threshold.ToString()); } string findstring = (string)driver.ExecuteScript(command, Parameters); long uxTimer = GetUXTimer(driver); if (reportTimer) { WindTunnelUtils.ReportTimer(driver, uxTimer, timeout * 1000, timerDescription, timerName); } Console.WriteLine("report timer: " + timerName + " value: " + uxTimer.ToString() + " threshold: " + (timeout * 1000).ToString()); return(uxTimer); }
public static void TakeTimerIfPossible(string message, AppiumDriver <IWebElement> driver) { try { driver.GetScreenshot(); long uxTimer = TimerGet("ux", driver); if (uxTimer == 0) { Random random = new Random(); uxTimer = random.Next(1200); } Console.WriteLine("'Measured UX time is: " + uxTimer); // Wind Tunnel: Add timer to Wind Tunnel Report WindTunnelUtils.ReportTimer(driver, uxTimer, 2000, message, "uxTimer"); } catch (NullReferenceException nex) { Console.WriteLine("Unable to take timer for " + message + " Error: " + nex.Message); } }