public static AttributeConstraint GetControl(IE ie, HControl control) { //Regex regex = new Regex(FilterPattern.GetToPattern(control.Value)); String regex = control.Value; switch (control.Attribute.ToLower()) { case AttributeType.Id: return(Find.ById(regex)); case AttributeType.Name: return(Find.ByName(regex)); case AttributeType.Class: return(Find.ByClass(regex)); case AttributeType.Text: { Regex regexs = new Regex(FilterPattern.GetToPattern(control.Value)); return(Find.ByText(regexs)); } case AttributeType.Value: { Regex regexs = new Regex(FilterPattern.GetToPattern(control.Value)); return(Find.ByValue(regexs)); } default: return(Find.ByName(regex)); } }
public static bool IsExist(IE ie, HControl control) { try { bool existed = true; Regex regex = new Regex(FilterPattern.GetToPattern(control.Value)); switch (control.Control.ToLower()) { case ControlType.AHref: existed = ie.Link(Find.ByText(regex)).Exists; break; case ControlType.AHrefNoText: try { } catch (Exception ex) { existed = false; } break; case ControlType.Button: existed = ie.Button(GetControl(ie, control)).Exists; break; case ControlType.Div: existed = ie.Div(GetControl(ie, control)).Exists; break; case ControlType.TextArea: existed = ie.TextField(GetControl(ie, control)).Exists; break; case ControlType.TextBox: existed = ie.TextField(GetControl(ie, control)).Exists; break; } return(existed);// } catch (Exception ex) { return(false); } }