I'm trying to select a dropdown with selenium C #, but as we can see in the HTML below there is no "ID" or "Name", below the code how am I doing, could you help me?
<select ng-model="vm.activeWhatsapp.channel_id"
ng-options="channel.id as channel.display_name group by channel.sector.name for channel in vm.whatsappChannels"
class="ng-pristine ng-valid ng-empty ng-touched">
<option value="?" selected="selected">
</option>
<optgroup label="Itaú Cartões Ativo">
<option label="Liderança - Itaú Cartões Ativo" value="number:1325">Liderança - Itaú Cartões Ativo</option>
</optgroup>
</select>
//Selecting a drop down control
public static void SelectDropDown(IWebDriver driver, string element, string value, string elementtype)
{
if (elementtype == "Id")
new SelectElement(driver.FindElement(By.Id(element))).SelectByText(value);
if (elementtype == "Name")
new SelectElement(driver.FindElement(By.Name(element))).SelectByText(value);
if (elementtype == "Class")
new SelectElement(driver.FindElement(By.CssSelector(element))).SelectByValue(value);
SeleniumSetMethods.SelectDropDown(drive, ".ng-pristine.ng-valid.ng-empty.ng-touched", "1325", "Class");