views:

121

answers:

1

HI

how can i check if all elements in an array i created are present in a drop down menu using selenium testing?

i have something like this but dosent seem to work

ANIMALS = ["snake","cat","dog"]

def validate_all_animals_exist(selenium)

  ANIMALS.each { |animal| assert selenium.is_element_present(animal), "Expected category [#{animal}] to be present" }

end

thanks in advance

+1  A: 

You need to use the verifySelectOptions call

verifySelectOptions(selectLocator, pattern) Generated from getSelectOptions(selectLocator) Arguments:

    * selectLocator - an element locator identifying a drop-down menu

Returns:
    an array of all option labels in the specified select drop-down

Gets all option labels in the specified select drop-down.

So it would be

assert_equal "123123", page.get_select_options("foo").join(",")
AutomatedTester