Another Salesforce blog!!!

Salesforce, Apex

October, 2012

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

ExecuteNonQuery / ExecuteScalar

Namespaces: System.Data; System.Xml; System.Configuration; // Clear out any test records from previous test executions. using (System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings[“DB_NAME”].ConnectionString)) { connection.Open(); string _mediaId = string.Empty; string _title = “Title”; using (System.Data.SqlClient.SqlCommand cmd = connection.CreateCommand() as System.Data.SqlClient.SqlCommand) { System.Data.SqlClient.SqlCommand cmd1 = new System.Data.SqlClient.SqlCommand(sql, connection); cmd1.CommandType = CommandType.Text; using (System.Data.SqlClient.SqlDataReader reader = cmd1.ExecuteReader()) { while (reader.Read()) […]

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