public WatiN.Core.Element FindButton(string locator, Scope scope) { var isButton = Constraints.OfType <Button>() | Find.ByElement(e => e.TagName == "INPUT" && e.GetAttributeValue("type") == "image") | Find.By("role", "button"); var byText = Find.ByText(locator); var byIdNameValueOrAlt = Find.ById(locator) | Find.ByName(locator) | Find.ByValue(locator) | Find.ByAlt(locator); var byPartialId = Constraints.WithPartialId(locator); var hasLocator = byText | byIdNameValueOrAlt | byPartialId; var isVisible = Constraints.IsVisible(scope.ConsiderInvisibleElements); var candidates = WatiNScope(scope).Elements.Filter(isButton & hasLocator & isVisible); return(candidates.FirstMatching(byText, byIdNameValueOrAlt, byPartialId)); }
public WatiN.Core.Element FindField(string locator, Scope scope) { var field = FindFieldByLabel(locator, scope); if (field == null) { var isField = Constraints.IsField(); var byIdOrName = Find.ById(locator) | Find.ByName(locator); var byPlaceholder = Find.By("placeholder", locator); var radioButtonOrCheckboxByValue = (Constraints.OfType <RadioButton>() | Constraints.OfType <CheckBox>()) & Find.ByValue(locator); var byPartialId = Constraints.WithPartialId(locator); var hasLocator = byIdOrName | byPlaceholder | radioButtonOrCheckboxByValue | byPartialId; var isVisible = Constraints.IsVisible(scope.ConsiderInvisibleElements); var candidates = WatiNScope(scope).Elements.Filter(isField & hasLocator & isVisible); field = candidates.FirstMatching(byIdOrName, byPlaceholder, radioButtonOrCheckboxByValue, byPartialId); } return(field); }