Beispiel #1
0
 def get_submit_action(self, state):
     submit_button = self.find_input(state, [ElementType.SUBMIT])
     if submit_button is None:
         raise Exception("Can't find submit_button ")
     submit = action_builder.get_click_action(submit_button, state, state)
     submit.execute(self.driver, self.config)
     new_state = state_builder.get_new_state(self.driver, state)
     new_state.save()
     submit.end_state = new_state
     return submit
Beispiel #2
0
 def get_type_password_action(self, state):
     password_field = self.find_input(state, [ElementType.PASSWORD])
     if password_field is None:
         raise Exception("Can't find password field")
     type_password = action_builder.get_sendkeys_action(
         password_field, state, state)
     type_password.execute(self.driver, self.config)
     new_state = state_builder.get_new_state(self.driver, state)
     new_state.save()
     type_password.end_state = new_state
     return type_password
Beispiel #3
0
 def get_type_username_action(self, state):
     username_field = self.find_input(
         state, [ElementType.USERNAME, ElementType.LOGIN])
     if username_field is None:
         raise Exception("Can't find username field")
     send_username = action_builder.get_sendkeys_action(
         username_field, state, state)
     send_username.execute(self.driver, self.config)
     new_state = state_builder.get_new_state(self.driver, state)
     new_state.save()
     send_username.end_state = new_state
     return send_username
Beispiel #4
0
 def test_builder_reuses_elements(self):
     self.url = "http://www.google.com/"
     self.driver.get(self.url)
     state = state_builder.get_current_state(self.driver)
     new_state = state_builder.get_new_state(self.driver, state)
     for newelement in new_state.elements:
         found = False
         for stateelement in state.elements:
             if newelement.id == stateelement.id:
                 found = True
         if not found:
             assert found, "Element ID not found, element was not reused %s" % newelement.locators
Beispiel #5
0
 def get_click_login_action(self, state):
     username_field = self.find_input(
         state, [ElementType.USERNAME, ElementType.LOGIN])
     if username_field is not None:
         return None
     else:
         click_login = action_builder.get_click_action(
             self.login_link, self.start_state, self.end_state)
         click_login.execute(self.driver, self.config)
         new_state = state_builder.get_new_state(self.driver, state)
         new_state.save()
         click_login.end_state = new_state
         click_login.save()
         return click_login
Beispiel #6
0
    def test_buidler_reuses_some_elemnts(self):
        self.url = "http://www.google.com/"
        self.driver.get(self.url)
        state = state_builder.get_current_state(self.driver)
        self.driver.get("https://images.google.com/?gws_rd=ssl")
        new_state = state_builder.get_new_state(self.driver, state)
        count = 0
        for newelement in new_state.elements:
            found = False
            for stateelement in state.elements:
                if newelement.id == stateelement.id:
                    count += 1

        assert count >= 10, count