def test_complex_widget_with_multiple_iframes(self): widget = testingwebpages.MyComplexWidget(self.driver, Locator.by_xpath("//widget")) visible_widget = testingwebpages.MyComplexWidget( self.driver, Locator.by_xpath("//widget")) visible_widget.visible_iframe = testingwebpages.MyComplexIframe( self.driver, Locator.by_xpath("//iframe1")) widget.visible_widget = visible_widget widget.visible_iframe = testingwebpages.MyComplexIframe( self.driver, Locator.by_xpath("//iframe2")) # Widgets currently do not have a check if there are multiple iframes defined widget.get_element_attr()
def test_complex_page_with_multiple_iframes(self): page = testingwebpages.MyComplexPage(self.driver) visible_widget = testingwebpages.MyComplexWidget( self.driver, Locator.by_xpath("//widget")) visible_widget.visible_iframe = testingwebpages.MyComplexIframe( self.driver, Locator.by_xpath("//iframe1")) page.visible_widget = visible_widget page.visible_iframe = testingwebpages.MyComplexIframe( self.driver, Locator.by_xpath("//iframe2")) try: page.get_element_attr() assert False, "Expecting to throw an AttributeError because 2 iframes were defined on a page" except AttributeError: pass
def test_get_element_attr_dict_with_iframe(self): page = testingwebpages.MyComplexPage(self.driver) visible_iframe = testingwebpages.MyComplexIframe( self.driver, Locator.by_xpath("//iframe")) page.visible_iframe = visible_iframe elements = page.get_element_attr(result_type=dict) assert len(elements) == 4, 'Expecting 4 elements' assert 'regular_element' in elements assert 'invisible_element' in elements assert 'not_checked_element' in elements assert 'visible_iframe' in elements
def test_get_element_attr_dict_with_iframe(self): widget = testingwebpages.MyComplexWidget(self.driver, Locator.by_xpath("//widget")) visible_iframe = testingwebpages.MyComplexIframe( self.driver, Locator.by_xpath("//iframe")) widget.visible_iframe = visible_iframe elements = widget.get_element_attr(result_type=dict) assert len(elements) == 5, 'Expecting 5 elements' assert 'widget' in elements assert 'regular_element_on_widget' in elements assert 'invisible_element_on_widget' in elements assert 'not_checked_element_on_widget' in elements assert 'visible_iframe' in elements
def test_access_element_not_definedy_on_webpage(self): page = testingwebpages.MyComplexPage(self.driver) visible_iframe = testingwebpages.MyComplexIframe( self.driver, Locator.by_xpath("//iframe")) visible_widget = testingwebpages.MyComplexWidget( self.driver, Locator.by_xpath("//widget")) page.visible_iframe = visible_iframe page.visible_widget = visible_widget try: page.foobar assert False, "Expecting page.foobar to throw an AttributeError!" except AttributeError: pass
def test_complex_page_with_iframe(self): page = testingwebpages.MyComplexPage(self.driver) page.visible_iframe = testingwebpages.MyComplexIframe( self.driver, Locator.by_xpath("//iframe")) elements = page.get_element_attr() meta_data = self.calculate_meta(elements) assert len( elements ) == 4, "Expecting there to be 4 elements in this test complex page" assert meta_data['types'][ 'element'] == 3, "Expecting there to be 3 Element types" assert meta_data['types'][ 'iframe'] == 1, "Expecting there to be 1 IFrame types" assert meta_data['visible'] == 2, "Expecting there to be 2 visible" assert meta_data['invisible'] == 1, "Expecting there to be 1 invisible" assert meta_data[ 'do-not-check'] == 1, "Expecting there to be 1 do-not-check"
def test_complex_widget_with_iframe(self): widget = testingwebpages.MyComplexWidget(self.driver, Locator.by_xpath("//widget")) widget.visible_iframe = testingwebpages.MyComplexIframe( self.driver, Locator.by_xpath("//iframe")) elements = widget.get_element_attr() meta_data = self.calculate_meta(elements) assert len( elements ) == 5, "Expecting there to be 5 elements in this test complex widget" assert meta_data['types'][ 'element'] == 3, "Expecting there to be 3 Element types" assert meta_data['types'][ 'widget'] == 1, "Expecting there to be 1 Widget types" assert meta_data['types'][ 'iframe'] == 1, "Expecting there to be 1 IFrame types" assert meta_data['visible'] == 3, "Expecting there to be 3 visible" assert meta_data['invisible'] == 1, "Expecting there to be 1 invisible" assert meta_data[ 'do-not-check'] == 1, "Expecting there to be 1 do-not-check"
def test_access_element_not_defined_directly_on_webpage_with_duplicates( self): page = testingwebpages.MyComplexPage(self.driver) visible_iframe = testingwebpages.MyComplexIframe( self.driver, Locator.by_xpath("//iframe")) visible_widget = testingwebpages.MyComplexWidget( self.driver, Locator.by_xpath("//widget")) page.visible_iframe = visible_iframe page.visible_widget = visible_widget # None of these should throw an AttributeError page.regular_element page.invisible_element page.not_checked_element page.visible_iframe page.visible_iframe_regular_element page.visible_iframe_invisible_element page.visible_iframe_not_checked_element page.visible_widget page.regular_element_on_widget page.invisible_element_on_widget page.not_checked_element_on_widget
def test_complex_page_with_widget_iframe(self): page = testingwebpages.MyComplexPage(self.driver) visible_widget = testingwebpages.MyComplexWidget( self.driver, Locator.by_xpath("//widget")) visible_widget.visible_iframe = testingwebpages.MyComplexIframe( self.driver, Locator.by_xpath("//iframe")) page.visible_widget = visible_widget elements = page.get_element_attr() meta_data = self.calculate_meta(elements) assert len( elements ) == 8, "Expecting there to be 8 elements in this test complex page" assert meta_data['types'][ 'element'] == 6, "Expecting there to be 6 Element types" assert meta_data['types'][ 'widget'] == 1, "Expecting there to be 1 Widget types" assert meta_data['types'][ 'iframe'] == 1, "Expecting there to be 1 IFrame types" assert meta_data['visible'] == 4, "Expecting there to be 4 visible" assert meta_data['invisible'] == 2, "Expecting there to be 2 invisible" assert meta_data[ 'do-not-check'] == 2, "Expecting there to be 2 do-not-check"