SeleniumLibrary icon indicating copy to clipboard operation
SeleniumLibrary copied to clipboard

the keyword "select frame " dose not work well

Open lucasliu opened this issue 14 years ago • 3 comments

The key word 'select frame' can't recoginze iframes which are dynamic genrerated by Ajax.

I tried selenium2 python binding it works fine.

so I checked source code (_browsermanagement.py) and made some change,then, It worked. I wonder the function of the two lines ( I can't find the realizition of _element_find.) #element = self._element_find(locator, True, True, tag='frame') #self._current_browser().switch_to_frame(element)


def select_frame(self, locator):
    """Sets frame identified by `locator` as current frame.

    Key attributes for frames are `id` and `name.` See `introduction` for
    details about locating elements.
    """
    self._info("Selecting frame '%s'." % locator)
    #element = self._element_find(locator, True, True, tag='frame')
    #self._current_browser().switch_to_frame(element)
    self._current_browser().switch_to_frame(locator)

lucasliu avatar Mar 02 '12 01:03 lucasliu

I also faced the same situation. The issue is in

element = self._element_find(locator, True, True, tag='frame')

in tag='frame'

because in class ElementFinder no logic to handle frame tag

def _get_tag_and_constraints(self, tag): if tag is None: return None, {}

    tag = tag.lower()
    constraints = {}
    if tag == 'link':
        tag = 'a'
    elif tag == 'image':
        tag = 'img'
    elif tag == 'list':
        tag = 'select'
    elif tag == 'radio button':
        tag = 'input'
        constraints['type'] = 'radio'
    elif tag == 'checkbox':
        tag = 'input'
        constraints['type'] = 'checkbox'
    elif tag == 'text field':
        tag = 'input'
        constraints['type'] = 'text'
    elif tag == 'file upload':
        tag = 'input'
        constraints['type'] = 'file'
    return tag, constraints

Therefore need to hack code to make it work, like this

element = self._element_find(locator, True, True)

poliarush avatar Mar 03 '12 07:03 poliarush

Please see the fix in issue 21 for this iframe issue

adwu73 avatar Mar 10 '12 02:03 adwu73

@lucasliu @polusok @adwu73 : This issue has been fixed in #71.

emanlove avatar Jun 30 '12 01:06 emanlove