Solve the problem that select frame in Selenium2Library cannot select frame with no name or id or iframe. selenium2library
The original select_frame function in Selenium2Library (the corresponding keyword is select frame) can select frame based on locator. However, if a frame or iframe has no id and no name, if multiple frames or iframe exist on the page, the original function cannot select the frame or iframe. The reason is that the default locator option of the original function can be unique.
Solution: Modify the select_frame function in Selenium2Library and support the index selection function.
Locate % PythonHome % \ Lib \ site-packages \ Selenium2Library \ keywords \ _ browsermanagement. py
Open it and find the select_frame method.
Modify the code to the following: the modified select_frame function is as follows:
def select_frame(self, locator, index): """Sets frame identified by `locator` as current frame if 'locator' is not unique, use index Key attributes for frames are `id` and `name.` See `introduction` for details about locating elements. """ if locator.startswith("tag") : elements = self._element_find(locator, False, True) element = elements[int(index)] else: element = self._element_find(locator, True, True) self._current_browser().switch_to_frame(element)
In this case, you can select the frame
Select frame |
Tag = iframe |
1 |