Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/Selenium2Library/keywords/_browsermanagement.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,18 @@ def select_frame(self, locator):
details about locating elements.
"""
self._info("Selecting frame '%s'." % locator)
element = self._element_find(locator, True, True, tag='frame')
try:
element = self._element_find(locator, True, True, tag='iframe')
except ValueError:
element = self._element_find(locator, True, True, tag='frame')
self._current_browser().switch_to_frame(element)

def select_window(self, locator=None):
"""Selects the window found with `locator` as the context of actions.

If the window is found, all subsequent commands use that window, until
this keyword is used again. If the window is not found, this keyword fails.

By default, when a locator value is provided,
it is matched against the title of the window and the
javascript name of the window. If multiple windows with
Expand Down
9 changes: 6 additions & 3 deletions src/Selenium2Library/keywords/_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,10 @@ 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')
try:
element = self._element_find(locator, True, True, 'iframe')
except ValueError:
element = self._element_find(locator, True, True, 'frame')
browser.switch_to_frame(element)
self._info("Searching for text from frame '%s'." % locator)
found = self._is_text_present(text)
Expand Down Expand Up @@ -588,8 +591,8 @@ 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("tag=iframe", False, False, 'iframe') + \
self._element_find("tag=frame", False, False, 'frame')
self._debug('Current frame has %d subframes' % len(subframes))
for frame in subframes:
browser.switch_to_frame(frame)
Expand Down
4 changes: 4 additions & 0 deletions test/acceptance/keywords/content_assertions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ Page Should Contain With Frames
[Setup] Go To Page "frames/frameset.html"
Page Should Contain You're looking at right.

Page Should Contain With IFrames
[Setup] Go To Page "frames/iframes.html"
Page Should Contain You're looking at right.

Page Should Not Contain
[Documentation] LOG 2:5 Current page does not contain text 'non existing text'. LOG 3.1:4 REGEXP: (?i)<html .*</html>
Page Should Not Contain non existing text
Expand Down
15 changes: 15 additions & 0 deletions test/acceptance/keywords/frames.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,25 @@ 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


Select And Unselect Frame
[Documentation] LOG 2 Selecting frame 'left'.
Select Frame left
Click Link foo
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.
4 changes: 4 additions & 0 deletions test/resources/html/frames/iframes.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<html>
<iframe name ="left" id="left" src="left.html"></iframe>
<iframe name="right" id="right" src="right.html"></iframe>
</html>