Adding "select" tags management in specflow tests

--HG--
branch : dev
extra : transplant_source : %9C/%97%155%22%94w%07%FF%0A%0D5%02%ED%C3.%97%8E%C9
This commit is contained in:
Sebastien Ros
2011-01-26 08:18:08 -08:00
parent 3826bc606f
commit 1041dd66cb

View File

@@ -206,7 +206,7 @@ namespace Orchard.Specs.Bindings {
[When(@"I fill in")]
public void WhenIFillIn(Table table) {
var inputs = _doc.DocumentNode
.SelectNodes("(//input|//textarea)") ?? Enumerable.Empty<HtmlNode>();
.SelectNodes("(//input|//textarea|//select)") ?? Enumerable.Empty<HtmlNode>();
foreach (var row in table.Rows) {
var r = row;
@@ -244,7 +244,19 @@ namespace Orchard.Specs.Bindings {
break;
default:
input.Attributes.Add("value", row["value"]);
if (string.Equals(input.Name, "select", StringComparison.OrdinalIgnoreCase)) {
var options = input.ChildNodes;
foreach (var option in options) {
if (option.GetAttributeValue("value", "") == row["value"])
option.Attributes.Add("selected", "selected");
else if (option.Attributes.Contains("selected"))
option.Attributes.Remove("selected");
}
}
else {
input.Attributes.Add("value", row["value"]);
}
break;
}
}