It’s easy to get to know if particular option is available in drop-down field, as we just select that option and it verifies that…OK option is available. However if we want to verify that particular option is not available in some drop-down field then we need to think about some trick. One of trick is given below to get to know that option is not available-
public Boolean CheckOption(browser, String DropDownObjectID, String Option)
HtmlComboBox SelectObject = new HtmlComboBox(browser);
String Selectoption = SelectObject.GetContent();
Boolean result = false;
foreach (String data in Selectoption)
I invested many hours to find out that how we can identify class: ‘HtmlTag.A’ object? Eventually I have found that we can use ‘HtmlCustom’ class to identify ‘HtmlTag.A’ object. Below syntax will help to find it and click on it-
HtmlCustom Tab = new HtmlCustom(browser);
Tab.SearchProperties.Add(“InnerText”, “ManageUser”, “TagName”, “A”);
Provide your comment if it is not working in your case.
If you have calendar which have Month and Year drop-downs and date in tags then follow below code to select the date from the calendar
HtmlImage calImage = new HtmlImage(browser);
cal.SearchProperties.Add(“Id”, “ImageID”); //It finds the ‘V’ image of calendar to open.
Mouse.Click(cal); //It opens the calender.
HtmlComboBox Month = new HtmlComboBox (browser);
Month.SearchProperties.Add(“Id”, “MonthDropDownID”); //It finds the Month drop-down field.
Month.SetProperty(“SelectedItem”, “December”); //It selects provided Month in drop-down field.
HtmlComboBox Year = new HtmlComboBox (browser);
Year.SearchProperties.Add(“Id”, “YearDropDownID”); //It finds the Year drop-down field.
Year.SetProperty(“SelectedItem”, “2015”); //It selects provided Year in drop-down field.
HtmlTable Calender = new HtmlTable(browser);
Calender.SearchProperties.Add(“Id”, “CalenderTableID”); //It finds the Calender table.
HtmlCell date = new HtmlCell(Cal);
date.SearchProperties.Add(“InnerText”, “31”); //It find provided date by InnerText.
Mouse.Click(date); //It selects provided Date from the Calender.
Below code will help to select values in drop-down field-
HtmlComboBox State = new HtmlComboBox(browser);
If you want to get by default selected value from Drop-Down field then use below method to get that-