How to get all matching elements without scrolling using robot frame and python?

I need to get ALL elements matching xpath with the list, without having to scroll to all elements, because I never know if scroll is needed (it depends on the resolution of the monitor, and the width of the columns can also be changed by developers) and I don't know where to scroll , because I check for the presence of columns, and in some cases the correct result is also that the column is not there ...

I use these functions in a test to get a list of column headers:

Get all columns of table ${table}
    ${columns_loc}=  replace substring placeholder ${GRID_HEADERS}  ${table}
    @{locators}=   Get Webelements    ${columns_loc}
    ${result}=       Create List
    :FOR   ${locator}   in    @{locators}
    \       ${name}=    Get Text    ${locator}
    \       Append To List  ${result}  ${name}
    [Return]   ${result}

Check column ${column} is visible
   ${headers2}=  Get all values
   ${res}=  value is in list   ${headers2}   ${column}
   run keyword if    ${res}==False  fail  wrong columns displayed
...                  else  pass execution

I also tried using this:

def dict_elements(self, xpath):
    elements = self.get_library_instance()._element_find(xpath, False, True)
    headers_map = {}
    if elements is not None:
        for index, element in enumerate(elements):
            headers_map[element.text] = index
        return headers_map
    return None

def list_elements(self, xpath):
    dict = self.dict_elements(xpath)
    return dictionary_keys_to_list(dict)

Get all columns of table ${table}
    ${columns_loc}=  replace substring placeholder ${GRID_HEADERS}  ${table}
    @{cols}=  list elements  ${columns_loc}

9 - , 9 , EMPTY ( u'') (, u'last column name'). , , ... angular.

!

+4
2

Get Matching Xpath Count Get Matching Xpath Count .

0

, , , "" , - Selenium2Library Mouse Over.

, ; - / js scrollTo() .., - , , .. Mouse Over ( :) .

, :

:FOR   ${locator}   in    @{locators}
\       Mouse Over  ${locator}
\       ${name}=    Get Text    ${locator}
\       Append To List  ${result}  ${name}

, .


, , , , / , html, (value is in list - , Should Contain?)) - . 2 ç.;)

0

Source: https://habr.com/ru/post/1677004/


All Articles