public static void SelectOptionsTagsInTable(SelectTag ObjSelectTag, string strValue, string strControlName) { try { OptionTag opt1 = ObjSelectTag.FindSingle(".//option[@text='" + strValue + "']"); opt1.EnsureVisible(); opt1.Focus(); opt1.Selected = true; opt1.PerformClick(); Report.Info(strValue + " is selected in " + strControlName); } catch (Exception ex) { Report.Failure("Exception Occurred " + ex.Message); } }
/// <summary> /// Select the item from the OptionTag / Drop List /// </summary> /// <param name="DropButton">DropButton Object</param> /// <param name="selectBox">Select Tag / List</param> /// <param name="itemName">Option Tag / List Item</param> public static void SelectOption(ButtonTag DropButton, SelectTag selectBox, string itemName) { try { Delay.Milliseconds(200); DropButton.PressKeys("{Enter}"); Delay.Milliseconds(200); Report.Info("Selecting item '" + itemName + "' in " + selectBox); // ignore case regex string itemRegex = "^(?i)" + Regex.Escape(itemName) + "$"; selectBox.EnsureVisible(); OptionTag option = selectBox.FindSingle <OptionTag>("option[@InnerText~'" + itemName + "']"); option.Selected = true; Delay.Milliseconds(200); option.PressKeys("{Enter}"); } catch (Exception ex) { Report.Info("INFO", "Fail SelectOption : " + ex.Message); } }