I'm having issues in Chrome with a droplist that fires an event. I've read many of the posts and tried several options such as using the {Up}{Up} approach where once the item in the list is found, you arrow up (or down) to get to the option.
Here is the lastest version of my method:
Code: Select all
[UserCodeMethod]
public static void SelectFromDropDown_OL(RepoItemInfo dropList, string option)
{
Report.Log(ReportLevel.Info, "Keyboard", "Selecting '" + option +"' from " + dropList.Name);
SelectTag selectDL = dropList.CreateAdapter<SelectTag>(false);
int optionCount = selectDL.Options.Count;
for(int i = 1; i < optionCount; i++)
{
Report.Info("Index", i.ToString());
string text = selectDL.Options[i].InnerText.ToString();
string tagValue = selectDL.Options[i].TagValue.ToString();
if(text.Equals(option, StringComparison.CurrentCultureIgnoreCase))
{
Report.Info("Text equal", text);
// selectDL.Click();
switch (option) {
case "Bank Card":
Report.Info("Bank Card matched", "3 ups");
selectDL.PressKeys("{Up}{Up}{Up}{Return}");
break;
case "Card (Auto)":
Report.Info("Card (Auto) matched", "2 ups");
selectDL.PressKeys("{Up}{Up}{Return}");
break;
case "Cart":
Report.Info("Cart matched", "1 up");
selectDL.PressKeys("{Up}");
break;
case "Cash":
Report.Info("Cash default", "No up");
break;
case "Cashier's Check":
Report.Info("Cashier's Check matched", "1 down");
selectDL.PressKeys("{Down}{Return}");
break;
case "Collections Check":
Report.Info("Collections Check matched", "2 down");
selectDL.PressKeys("{Down}{Down}{Return}");
break;
case "Credit Card (Manual)":
Report.Info("Credit Card matched", "3 down");
selectDL.PressKeys("{Down}{Down}{Down}");
break;
case "Insurance Check":
Report.Info("Insurance Check matched", "4 down");
selectDL.PressKeys("{Down}{Down}{Down}{Down}");
break;
case "Money Order":
Report.Info("Money Order matched", "5 down");
selectDL.PressKeys("{Down}{Down}{Down}{Down}{Down}");
break;
case "Personal Check":
Report.Info("Personal Check matched", "6 down");
selectDL.PressKeys("{Down}{Down}{Down}{Down}{Down}{Down}");
break;
case "Western Union":
Report.Info("Western Union matched", "7 down");
selectDL.PressKeys("{Down}{Down}{Down}{Down}{Down}{Down}{Down}");
break;
default:
Report.Info("Default Switch Done", "");
break;
}
selectDL.PressKeys("{Return}");
break;
}
}
Below is the markup for the small form that has the droplist and a couple of text fields.
The Element
DLPaymentMethod .//select[@id<'elmPmtTender_ddlMethod']