<h5 _ngcontent-c2="" class="card-title">Payment Mode </h5>
<!---->
<div _ngcontent-c2="">
<div _ngcontent-c2="" class="form-group">
<input _ngcontent-c2="" name="paymentmode" type="radio" style="">
<b _ngcontent-c2="">Credit Card</b>
</div>
</div>
<div _ngcontent-c2="">
<div _ngcontent-c2="" class="form-group">
<input _ngcontent-c2="" name="paymentmode" type="radio">
<b _ngcontent-c2="">Debit Card</b>
</div>
</div>
<div _ngcontent-c2="">
<div _ngcontent-c2="" class="form-group">
<input _ngcontent-c2="" name="paymentmode" type="radio">
<b _ngcontent-c2="">Net Banking</b>
</div>
</div>
<div _ngcontent-c2="">
<div _ngcontent-c2="" class="form-group">
<input _ngcontent-c2="" name="paymentmode" type="radio">
<b _ngcontent-c2="">UPI</b>
</div>
</div>
For above HTML, i am trying to select radio button based on value of radio button. I am using Protractor NuGet package along with selenium webdriver.
IList<NgWebElement> oCheckBox = ngDriver.FindElements(By.XPath("//input[@name='paymentmode']"));
int Size = oCheckBox.Count;
for (int i = 0; i < Size; i++)
{
String Value = oCheckBox.ElementAt(i).GetAttribute("value");
if (Value.Equals("Net Banking"))
{
oCheckBox.ElementAt(i).Click();
break;
}
}
but IList<NgWebElement>
does not contain definition for ElementAt
.
Is there any way arount to select radio button based on payment mode?
You can use an XPath to find the radio button by contained text, "Net Banking"
//input[@name='paymentmode']/following::b[.='Net Banking'][1]
I would put this in a method and pass in the value you are looking for to make it more flexible.