Skip to content

Commit

Permalink
now checks for button element along with inout tyoe button
Browse files Browse the repository at this point in the history
  • Loading branch information
Shashank Shetty committed Jan 26, 2014
1 parent 16b702c commit c4d1239
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions src/FluentBrowserAutomation/BrowserContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,22 @@ public ButtonWrapper ButtonWithId(string id)
public ButtonWrapper ButtonWithText(string text)
{
const string howFound = "button with visible text '{0}'";
var button = Buttons().FirstOrDefault(x => x.Element.GetAttribute("value") == text);
var button = Buttons().FirstOrDefault(x =>
{
var buttonText = x.Element.TagName == "button" ? x.Element.Text : x.Element.GetAttribute("value");
return buttonText == text;
});
return new ButtonWrapper(button == null ? null : button.Element, String.Format(howFound, text), this);
}

public IEnumerable<ButtonWrapper> Buttons()
{
const string howFound = "type 'button'";
return from input in GetInputs().AsParallel()
where IsButton(input)
select new ButtonWrapper(input, howFound, this);
var inputWrappers = GetInputs().Where(IsButton).Select(input => new ButtonWrapper(input, howFound, this)).ToList();
var elementsByTagType = GetElementsByTagType("button");
var buttonWrappers = elementsByTagType.Select(button => new ButtonWrapper(button, howFound, this)).ToList();
inputWrappers.AddRange(buttonWrappers);
return inputWrappers;
}

public IEnumerable<ButtonWrapper> ButtonsWithClassName(string className)
Expand Down
2 changes: 1 addition & 1 deletion src/FluentBrowserAutomation/Controls/ButtonWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public string Text
{
if (_text == null)
{
_text = Element.GetAttribute("value");
_text = Element.TagName == "button" ? Element.Text : Element.GetAttribute("value");
}
return new ReadOnlyText("value of " + HowFound, _text);
}
Expand Down

0 comments on commit c4d1239

Please sign in to comment.