Skip to content

Enhance Get List Items to support returning values or labels #722

@qitaos

Description

@qitaos

@aaltat
I have a demo website http://demo.robotframework.cn/.
There is a select list, it's html code is:
snipaste20161228_091150

my case is:
snipaste20161228_091354

The keyword get_list_items docstring wrote it will return the values in the select list. But the result is:
snipaste20161228_091336

I want to get the option value for "item1","item2","item3", but it returns the labels "first","second","third".
So I checked the keyword get_list_items source code:
`

def get_list_items(self, locator):
    """Returns the values in the select list identified by `locator`.

    Select list keywords work on both lists and combo boxes. Key attributes for
    select lists are `id` and `name`. See `introduction` for details about
    locating elements.
    """
    select, options = self._get_select_list_options(locator)
    return self._get_labels_for_options(options)

`

It wrote 'returns the values', but it return self._get_labels_for_options(options).

I change the docstring to "Returns the labels", then add a keyword for get_list_values:
`

def get_list_values(self, locator):
    """Returns the values in the select list identified by `locator`.

    Select list keywords work on both lists and combo boxes. Key attributes for
    select lists are `id` and `name`. See `introduction` for details about
    locating elements.
    """
    select, options = self._get_select_list_options(locator)
    return self._get_values_for_options(options)

`

So this is the issue for the pr #721

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions