Reputation: 329
I want to pull the value of 3745 from the AGX9 Monaural pricing field so I can add it to a DataTable. However input.Text is coming up empty and I don't see that actual value of 3745 in the HTML for this page.
Here is the HTML for this input element:
<td class="monaural" ng-class="{'has-error' : vm.pricingForm[i].$invalid && vm.pricingForm[i].$dirty}" ng-init="i = ha + 'Monaural'">
<span class="caption caption-currency">$</span>
<input class="form-control price-control ng-pristine ng-valid ng-valid-required ng-valid-pattern ng-touched" type="text" required="" ng-pattern="/^[0-9]{3,5}(\.[0-9]{2})?$/" ng-model="vm.data[2][i].value" name="agx9Monaural">
</td>
Here is the code I am using to attempt to add the label, monaural, and binaural price to a DataTable.
foreach (IWebElement row in rows)
{
var inputFields = row.FindElements(By.TagName("input"));
//monoaural add to dataTableRow
dr[1] = inputFields[0].Text;
//binaural add to dataTableRow
dr[2] = inputFields[1].Text;
actualDataTable.Rows.Add(dr);
}
Upvotes: 3
Views: 3592
Reputation: 16201
You need to get the value
attribute
string value = Driver.FindElement(By.Name("agx9Monaural")).GetAttribute("value");
Should do it
In your case it would be
foreach (IWebElement row in rows)
{
var inputFields = row.FindElements(By.TagName("input"));
//monoaural add to dataTableRow
dr[1] = inputFields[0].GetAttribute("value");
//binaural add to dataTableRow
dr[2] = inputFields[1].GetAttribute("value");
actualDataTable.Rows.Add(dr);
}
Upvotes: 5