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);

Verifying if the text exists – Selenium WebDriver

I am using C# var webElements = (driver.FindElements(By.Id(“ctl00_ctl00_ctl00_lstPreviewCards”))).ToList(); int found = webElements.FindIndex(item => item.Text.Contains(NAME)); if (found == 0) { return true; }