Esempio n. 1
0
 def test_component_is_not_found_when_trait_raises_an_exception(self):
     component = UIComponent(self.driver, 'a_component', [By.ID, 'an_id'])
     ##
     component.add_trait(raise_exception, 'always true')
     ##
     assert_that(component.is_found(), equal_to(False),
                 "component should not be found when evaluating traits throws an exception")
Esempio n. 2
0
 def test_component_is_found_when_has_all_traits(self):
     component = UIComponent(self.driver, 'a_component', [By.ID, 'an_id'])
     ##
     component.add_trait(lambda: True, 'always true')
     ##
     assert_that(component.is_found(), equal_to(True),
                 "component should be found when all traits are present")
Esempio n. 3
0
    def test_is_present(self):
        self.driver.set_dom_element([By.ID, 'an_id'])
        component = UIComponent(self.driver, 'a_component', [By.ID, 'an_id'])

        component.is_present()

        assert_that(self.driver.has_fulfilled_expectations(), equal_to(True),
                    "component should be able to locate element it is scope")
Esempio n. 4
0
 def test_component_can_be_created_from_web_element(self):
     component = UIComponent(self.driver, 'a component', [By.ID, 'theId'])
     a_web_element = WebElement(None, '')
     ##
     component.from_web_element(a_web_element)
     ##
     assert_that(component.locate(), equal_to(a_web_element),
                 "fromWebElement should store a reference to passed WebElement")
Esempio n. 5
0
    def test_is_present(self):
        self.driver.set_dom_element([By.ID, 'an_id'])
        component = UIComponent(self.driver, 'a_component', [By.ID, 'an_id'])

        component.is_present()

        assert_that(self.driver.has_fulfilled_expectations(), equal_to(True),
                    "component should be able to locate element it is scope")
Esempio n. 6
0
 def test_component_can_be_created_from_web_element(self):
     component = UIComponent(self.driver, 'a component', [By.ID, 'theId'])
     a_web_element = WebElement(None, '')
     ##
     component.from_web_element(a_web_element)
     ##
     assert_that(
         component.locate(), equal_to(a_web_element),
         "fromWebElement should store a reference to passed WebElement")
Esempio n. 7
0
 def test_component_is_not_found_when_trait_raises_an_exception(self):
     component = UIComponent(self.driver, 'a_component', [By.ID, 'an_id'])
     ##
     component.add_trait(raise_exception, 'always true')
     ##
     assert_that(
         component.is_found(), equal_to(False),
         "component should not be found when evaluating traits throws an exception"
     )
Esempio n. 8
0
 def test_web_element_is_evaluated_every_time_without_caching(self):
     component = UIComponent(self.driver, 'a component', [By.ID, 'theid'])
     self.driver.set_dom_element([By.ID, 'theid'])
     element_first_time = component.locate()
     ##
     self.driver.reset_dom_elements()
     self.driver.set_dom_element([By.ID, 'theid'])
     element_second_time = component.locate()
     ##
     assert_that(element_first_time, is_not(equal_to(element_second_time)),
                 "when cached web_element() should return always the same WebElement object")
Esempio n. 9
0
 def test_component_can_be_hovered(self):
     self.driver.set_dom_element([By.ID, 'an_id'])
     self.driver.set_expected_command(Command.MOVE_TO, {'sessionId': self.driver.session_id,
                                                        'element': self.driver.get_id_for_stored_element(
                                                            [By.ID, 'an_id'])})
     component = UIComponent(self.driver, 'a_component', [By.ID, 'an_id'])
     ##
     component.hover()
     ##
     assert_that(self.driver.has_fulfilled_expectations(), equal_to(True),
                 "clicking on component should result in hoover command")
Esempio n. 10
0
    def test_component_can_be_clicked(self):
        self.driver.set_dom_element([By.ID, 'an_id'])

        self.driver.set_expected_command(Command.CLICK_ELEMENT, {'sessionId': self.driver.session_id,
                                         'id': self.driver.get_id_for_stored_element([By.ID, 'an_id'])})

        component = UIComponent(self.driver, 'a_component', [By.ID, 'an_id'])
        ##
        component.click()
        ##
        assert_that(self.driver.has_fulfilled_expectations(), equal_to(True),
                    "clicking on component should result in click command")
Esempio n. 11
0
 def test_web_element_is_evaluated_every_time_without_caching(self):
     component = UIComponent(self.driver, 'a component', [By.ID, 'theid'])
     self.driver.set_dom_element([By.ID, 'theid'])
     element_first_time = component.locate()
     ##
     self.driver.reset_dom_elements()
     self.driver.set_dom_element([By.ID, 'theid'])
     element_second_time = component.locate()
     ##
     assert_that(
         element_first_time, is_not(equal_to(element_second_time)),
         "when cached web_element() should return always the same WebElement object"
     )
Esempio n. 12
0
 def test_component_can_be_hovered(self):
     self.driver.set_dom_element([By.ID, 'an_id'])
     self.driver.set_expected_command(
         Command.MOVE_TO, {
             'sessionId': self.driver.session_id,
             'element': self.driver.get_id_for_stored_element(
                 [By.ID, 'an_id'])
         })
     component = UIComponent(self.driver, 'a_component', [By.ID, 'an_id'])
     ##
     component.hover()
     ##
     assert_that(self.driver.has_fulfilled_expectations(), equal_to(True),
                 "clicking on component should result in hoover command")
Esempio n. 13
0
    def test_has_element(self):
        self.driver.set_dom_element([By.ID, 'an_id'])
        component = UIComponent(self.driver, 'a_component', [By.ID, 'an_id'])
        self.driver.set_dom_element([By.XPATH, './/option'], parent_id=[By.ID, 'dropdownlocator'], children=1,
                                    return_values=[])

        self.driver.set_expected_command(Command.FIND_CHILD_ELEMENTS, {'using': By.ID, 'value': self.driver.
                                         get_id_for_stored_element([By.ID, 'an_id']),
                                         'id': 'id', "sessionId": self.driver.session_id})
        ##
        component.has_element([By.ID, 'another_id'])
        ##
        assert_that(self.driver.has_fulfilled_expectations(), equal_to(True),
                    "component should be able to locate element it is scope")
Esempio n. 14
0
 def __init__(self,
              driver,
              table_name,
              item_relative_locator,
              item_class,
              item_name,
              table_locator=None):
     UIComponent.__init__(self, driver, table_name, table_locator)
     ElementWithLanguage.__init__(self)
     if not issubclass(item_class, UIComponent):
         raise TypeError(
             "{0} is not subtype of UIComponent".format(item_name))
     self._item_relative_locator = item_relative_locator
     self._item_class = item_class
     self._item_name = item_name
Esempio n. 15
0
    def test_component_can_be_clicked(self):
        self.driver.set_dom_element([By.ID, 'an_id'])

        self.driver.set_expected_command(
            Command.CLICK_ELEMENT, {
                'sessionId': self.driver.session_id,
                'id': self.driver.get_id_for_stored_element([By.ID, 'an_id'])
            })

        component = UIComponent(self.driver, 'a_component', [By.ID, 'an_id'])
        ##
        component.click()
        ##
        assert_that(self.driver.has_fulfilled_expectations(), equal_to(True),
                    "clicking on component should result in click command")
Esempio n. 16
0
 def test_can_cache_element(self):
     component = UIComponent(self.driver, 'a_component', [By.ID, 'an_id'])
     component.cache()
     cached_element = MockedWebElement(self.driver, 'another_id')
     ##
     component._cache_web_element(cached_element)
     ##
     assert_that(component.locate(), equal_to(cached_element))
Esempio n. 17
0
    def test_has_element(self):
        self.driver.set_dom_element([By.ID, 'an_id'])
        component = UIComponent(self.driver, 'a_component', [By.ID, 'an_id'])
        self.driver.set_dom_element([By.XPATH, './/option'],
                                    parent_id=[By.ID, 'dropdownlocator'],
                                    children=1,
                                    return_values=[])

        self.driver.set_expected_command(
            Command.FIND_CHILD_ELEMENTS, {
                'using': By.ID,
                'value': self.driver.get_id_for_stored_element(
                    [By.ID, 'an_id']),
                'id': 'id',
                "sessionId": self.driver.session_id
            })
        ##
        component.has_element([By.ID, 'another_id'])
        ##
        assert_that(self.driver.has_fulfilled_expectations(), equal_to(True),
                    "component should be able to locate element it is scope")
Esempio n. 18
0
 def test_can_cache_element(self):
     component = UIComponent(self.driver, 'a_component', [By.ID, 'an_id'])
     component.cache()
     cached_element = MockedWebElement(self.driver, 'another_id')
     ##
     component._cache_web_element(cached_element)
     ##
     assert_that(component.locate(), equal_to(cached_element))
Esempio n. 19
0
 def __init__(self, driver, name):
     UIComponent.__init__(self, driver, name)
Esempio n. 20
0
 def test_component_is_found_when_has_all_traits(self):
     component = UIComponent(self.driver, 'a_component', [By.ID, 'an_id'])
     ##
     component.add_trait(lambda: True, 'always true')
     ##
     assert_that(component.is_found(), equal_to(True), "component should be found when all traits are present")
Esempio n. 21
0
 def __init__(self, driver, name='dropdown', locator=None):
     UIComponent.__init__(self, driver, name, locator)
Esempio n. 22
0
 def construct_from_foo():
     driver = MockedWebDriver()
     return UIComponent(driver, 'a component').from_web_element(Foo())
Esempio n. 23
0
 def __init__(self, driver, name='button', locator=None):
     UIComponent.__init__(self, driver, name, locator)
Esempio n. 24
0
 def __init__(self, driver, name='checkbox', locator=None):
     UIComponent.__init__(self, driver, name, locator)
Esempio n. 25
0
 def __init__(self, driver, name):
     UIComponent.__init__(self, driver, name)
Esempio n. 26
0
 def __init__(self, driver, name, locator=None):
     UIComponent.__init__(self, driver, name, locator)