Robot Framework SeleniumLibrary
frames.py
Go to the documentation of this file.
1 # Copyright 2008-2011 Nokia Networks
2 # Copyright 2011-2016 Ryan Tomac, Ed Manlove and contributors
3 # Copyright 2016- Robot Framework Foundation
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 
17 from SeleniumLibrary.base import LibraryComponent, keyword
18 
19 
21 
22  @keyword
23 
37  def select_frame(self, locator):
38  self.infoinfo("Selecting frame '%s'." % locator)
39  element = self.find_elementfind_element(locator)
40  self.driverdriverdriver.switch_to.frame(element)
41 
42  @keyword
43 
47  def unselect_frame(self):
48  self.driverdriverdriver.switch_to.default_content()
49 
50  @keyword
51 
59  def current_frame_should_contain(self, text, loglevel='TRACE'):
60  if not self.is_text_presentis_text_present(text):
61  self.log_sourcelog_source(loglevel)
62  raise AssertionError("Frame should have contained text '%s' "
63  "but did not." % text)
64  self.infoinfo("Current frame contains text '%s'." % text)
65 
66  @keyword
67 
72  def current_frame_should_not_contain(self, text, loglevel='TRACE'):
73  if self.is_text_presentis_text_present(text):
74  self.log_sourcelog_source(loglevel)
75  raise AssertionError("Frame should not have contained text '%s' "
76  "but it did." % text)
77  self.infoinfo("Current frame did not contain text '%s'." % text)
78 
79  @keyword
80 
88  def frame_should_contain(self, locator, text, loglevel='TRACE'):
89  if not self._frame_contains_frame_contains(locator, text):
90  self.log_sourcelog_source(loglevel)
91  raise AssertionError("Frame '%s' should have contained text '%s' "
92  "but did not." % (locator, text))
93  self.infoinfo("Frame '%s' contains text '%s'." % (locator, text))
94 
95  def _frame_contains(self, locator, text):
96  element = self.find_elementfind_element(locator)
97  self.driverdriverdriver.switch_to.frame(element)
98  self.infoinfo("Searching for text from frame '%s'." % locator)
99  found = self.is_text_presentis_text_present(text)
100  self.driverdriverdriver.switch_to.default_content()
101  return found
def find_element(self, locator, tag=None, required=True, parent=None)
Find element matching locator.
Definition: context.py:72
def current_frame_should_contain(self, text, loglevel='TRACE')
Verifies that current frame contains text.
Definition: frames.py:59
def current_frame_should_not_contain(self, text, loglevel='TRACE')
Verifies that current frame does not contains text.
Definition: frames.py:72
def frame_should_contain(self, locator, text, loglevel='TRACE')
Verifies that frame identified by locator contains text.
Definition: frames.py:88
def _frame_contains(self, locator, text)
Definition: frames.py:95
def unselect_frame(self)
Sets the main frame as the current frame.
Definition: frames.py:47
def select_frame(self, locator)
Sets frame identified by locator as the current frame.
Definition: frames.py:37