public virtual bool ValidateAll(string[][] kvps, bool ignoreCase = true) { WebDriverManager.WaitPageReady(); int length = kvps[0].Length; bool result = true; for (int i = 0; i < length; i++) { string controlName = kvps[0][i]; string value = kvps[1][i]; IUIControl iuiControl = ControlFromName(controlName); if (iuiControl == null || !iuiControl.IsVisible) { continue; } string text = iuiControl.Text; if (string.Equals(text, value) || (ignoreCase && string.Equals(text, value, StringComparison.OrdinalIgnoreCase))) { iuiControl.Highlight(DefaultMatchingHighlightScript); } else if (text.ContainsAll(value)) { iuiControl.Highlight(DefaultContainingHighlightScript); } else { iuiControl.Highlight(DefaultMismatchHighlightScript); result = false; } } return(result); }
// public static byte[] ToByteArray(this MediaTypeNames.Image image, ImageFormat format = null) // { // if (image == null) return null; // format = format ?? ImageFormat.Bmp; // using (MemoryStream ms = new MemoryStream()) // { // image.Save(ms, format); // return ms.ToArray(); // } // } // // public const PixelFormat DefaultPixelFormat = PixelFormat.Format24bppRgb; // public static byte[] AsBytes(this Bitmap bmp, Rectangle rect, PixelFormat format = DefaultPixelFormat) // { // if (bmp == null) return null; // //TODO: checking rect? // // byte[] bytes = null; // BitmapData bmpData = null; // try // { // bmpData = bmp.LockBits(rect, ImageLockMode.ReadOnly, format); // // // Get the address of the first line. // IntPtr ptr = bmpData.Scan0; // // // Declare an array to hold the bytes of the bitmap. // bytes = new byte[bmpData.Stride * bmpData.Height]; // // // Copy the RGB values into the array. // System.Runtime.InteropServices.Marshal.Copy(ptr, bytes, 0, bytes.Length); // } // finally // { // if (bmpData != null) // bmp.UnlockBits(bmpData); // } // // return bytes; // } // public static byte[] AsBytes(this Bitmap bmp, PixelFormat format = DefaultPixelFormat) // { // if (bmp == null) return null; // // Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height); // return AsBytes(bmp, rect, format); // } // // public static Bitmap FromBytes(this byte[] bytes, int width, int height, PixelFormat format = DefaultPixelFormat) // { // int bitsPerPixel = ((int)format & 0xff00) >> 8; // int bytesPerPixel = (bitsPerPixel + 7) / 8; // int stride = 4 * ((width * bytesPerPixel + 3) / 4); // // Bitmap bmp = new Bitmap(width, height, format); // BitmapData data = null; // try // { // data = bmp.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadWrite, format); // System.Runtime.InteropServices.Marshal.Copy(bytes, 0, data.Scan0, bytes.Length); // } // finally // { // if (data != null) bmp.UnlockBits(data); // } // // return bmp; // } // // public static void Update(this Dictionary<string, string> dict, string key, string value) // { // if (string.IsNullOrEmpty(key)) throw new ArgumentException(); // if (dict.ContainsKey(key)) // dict[key] = value; // else // { // dict.Add(key, value); // } // } public static bool HighlightAndMarked(this IUIControl iuiControl, string[] lines, List <string> validated) { string displayed = iuiControl.Text; if (displayed.ContainsAny(lines)) { validated.AddRange(lines.Where(l => !validated.Contains(l) && (displayed.ContainsIgnoreCase(l) || SimilarTo(l, displayed)))); iuiControl.Highlight(UIContainer.DefaultMatchingHighlightScript); return(true); } else { Logger.E("Failed to match '{0}' with given details", displayed); iuiControl.Highlight(UIContainer.DefaultMismatchHighlightScript); return(false); } }
public virtual bool HighlightAll(string[] keys) { foreach (var key in keys) { IUIControl iuiControl = ControlFromName(key); if (iuiControl == null || !iuiControl.WaitUntilVisible(2000)) { Logger.W("UIControl '{0}' is not visible.", iuiControl); return(false); } iuiControl.Highlight(); Logger.D("{0}='{1}'", key, iuiControl.Text); } return(true); }