diff --git a/CHANGES.rst b/CHANGES.rst index 4adc20930..dbdf867b5 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,11 @@ Release Notes ============= +1.1 (unreleased) +---------------- +- Added iframe support by removing strict filtering for only elements. + [emanlove] + 1.0.1 ----- - Support for Robot Framework 2.7 diff --git a/src/Selenium2Library/keywords/_browsermanagement.py b/src/Selenium2Library/keywords/_browsermanagement.py index 5be1cdcdb..8b1cba50c 100644 --- a/src/Selenium2Library/keywords/_browsermanagement.py +++ b/src/Selenium2Library/keywords/_browsermanagement.py @@ -173,7 +173,7 @@ def select_frame(self, locator): details about locating elements. """ self._info("Selecting frame '%s'." % locator) - element = self._element_find(locator, True, True, tag='frame') + element = self._element_find(locator, True, True) self._current_browser().switch_to_frame(element) def select_window(self, locator=None): diff --git a/src/Selenium2Library/keywords/_element.py b/src/Selenium2Library/keywords/_element.py index e107d526c..adf5e2885 100644 --- a/src/Selenium2Library/keywords/_element.py +++ b/src/Selenium2Library/keywords/_element.py @@ -508,7 +508,7 @@ def _element_find(self, locator, first_only, required, tag=None): def _frame_contains(self, locator, text): browser = self._current_browser() - element = self._element_find(locator, True, True, 'frame') + element = self._element_find(locator, True, True) browser.switch_to_frame(element) self._info("Searching for text from frame '%s'." % locator) found = self._is_text_present(text) @@ -589,7 +589,7 @@ def _page_contains(self, text): if self._is_text_present(text): return True - subframes = self._element_find("tag=frame", False, False, 'frame') + subframes = self._element_find("xpath=//frame|//iframe", False, False) self._debug('Current frame has %d subframes' % len(subframes)) for frame in subframes: browser.switch_to_frame(frame) diff --git a/test/acceptance/keywords/frames.txt b/test/acceptance/keywords/frames.txt index 94e5bd8e3..fd1cf261a 100644 --- a/test/acceptance/keywords/frames.txt +++ b/test/acceptance/keywords/frames.txt @@ -10,6 +10,22 @@ Frame Should Contain Frame Should contain right You're looking at right. Frame Should Contain left Links +Frame Should Contain should also work with iframes + [setup] Go To Page "frames/iframes.html" + Frame Should contain right You're looking at right. + Frame Should Contain left Links + + +Page Should Contain Text Within Frames + Page Should contain You're looking at right. + Page Should Contain Links + +Page Should Contain Text Within Frames should also work with iframes + [setup] Go To Page "frames/iframes.html" + Page Should contain You're looking at right. + Page Should Contain Links + + Select And Unselect Frame [Documentation] LOG 2 Selecting frame 'left'. Select Frame left @@ -17,3 +33,22 @@ Select And Unselect Frame Unselect Frame Select Frame right Current Frame Contains You're looking at foo. + +Select And Unselect Frame should also work with iframes + [Documentation] LOG 2 Selecting frame 'leftiframe'. + [setup] Go To Page "frames/iframes.html" + Select Frame left + Click Link foo + Unselect Frame + Select Frame right + Current Frame Contains You're looking at foo. + +Select Frame with non-unique name attribute + [Documentation] LOG 2 Descerning frame 'left' from link 'left'. + [setup] Go To Page "frames/poorlynamedframe.html" + Run Keyword And Expect Error NoSuchFrameException* Select Frame left + Select Frame xpath=//frame[@name='left']|//iframe[@name='left'] + Click Link foo + Unselect Frame + Select Frame right + Current Frame Contains You're looking at foo. \ No newline at end of file diff --git a/test/resources/html/frames/iframes.html b/test/resources/html/frames/iframes.html new file mode 100644 index 000000000..445ed72c2 --- /dev/null +++ b/test/resources/html/frames/iframes.html @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/test/resources/html/frames/poorlynamedframe.html b/test/resources/html/frames/poorlynamedframe.html new file mode 100644 index 000000000..5daf98620 --- /dev/null +++ b/test/resources/html/frames/poorlynamedframe.html @@ -0,0 +1,5 @@ + + Relative
+ + +