1

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

4
  • 2
    so write it. you want us to a) guess what all the id's are you used in your code and b) do your work for you? Commented May 15, 2019 at 10:48
  • 1
    What have you tried so far ? Paste your HTML code ? Commented May 15, 2019 at 11:13
  • <li class="header__country-selector--desktop__country"> <a href="/change-country?to=ae&amp;url=/news/3479291/Saudi-Arabia-to-introduce-new-residency-scheme-for-expatriates">UAE</a> </li> <li class="header__country-selector--desktop__country"> <a href="/change-country?to=bh&amp;url=/news/3479291/Saudi-Arabia-to-introduce-new-residency-scheme-for-expatriates">Bahrain</a> Commented May 15, 2019 at 11:39
  • 1) Tip: Add @Stultuske (or whoever, the @ 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. Commented May 15, 2019 at 13:10

2 Answers 2

1

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)
Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.