I have a list of dropdown predefine values from the web site as below
"KSA", "UAE", "Bahrain", "Oman", "Qatar", "Kuwait","Egypt","Jordan", "Tunisia" , "Morocco", "Palestine","Iraq"
need a helping selenium/ katalon code for click on those values
Put the countries in a list and if the dropdown is a select element, you can use the following code to select, for example "KSA":
def countries = ["KSA", "UAE", "Bahrain", "Oman", "Qatar", "Kuwait","Egypt","Jordan", "Tunisia" , "Morocco", "Palestine","Iraq"]
WebUI.click(findTestObject('dropdown-element'))
WebUI.selectOptionByValue(findTestObject('dropdown-element'), countries[0], false)
if you are using c#, then try this
IWebDriver driver = new ChromeDriver();
IList<IWebElement> dropdownLists = driver.FindElements(By.Id("yourdropdown"));
foreach (IWebElement item in dropdownLists)
{
if (item.Text.Equals("KSA"))
{
item.Click();
}
//if(item.Text.Equals("UAE")) ..... etc
}
you can also use a switch condition to select your place within the foreach statement
@is important) to notify the person of a new comment. 2) Please edit the question to add further information. 3) Be sure to use code formatting for code and code snippets, structured documents like HTML/XML or input/output. To do that, select the text and click the{}button at the top of the message posting/editing form.