Another Salesforce blog!!!

Salesforce, Apex

selected dropdownlist Text

In Webdriver, if you are looking to find a way to know what I have already been selected in dropdownlist then try this code….

   1:  var selectedItemText = (string)((IJavaScriptExecutor)driver).ExecuteScript("return arguments[0].options[arguments[0].selectedIndex].text;", element);
   2:  var selectedItemValue = (string)((IJavaScriptExecutor)driver).ExecuteScript("return arguments[0].options[arguments[0].selectedIndex].value;", element);
   3:  var selectedItemIndex = (long)((IJavaScriptExecutor)driver).ExecuteScript("return arguments[0].selectedIndex;", element);

Leave a Reply

Your email address will not be published. Required fields are marked *