Exemple #1
0
    def generate(self):
        actions = []
        self.driver.get(self.url)
        start_state = state_builder.get_current_state(self.driver)
        start_state.save()
        action = action_builder.get_nav_action(self.url, start_state)
        action.save()
        actions.append(action)
        self.click_login = self.get_click_login_action(start_state)
        if self.click_login is not None:
            new_state = self.click_login.end_state
        else:
            new_state = start_state
        self.type_username = self.get_type_username_action(new_state)
        new_state = self.type_username.end_state
        self.submit_user = self.get_submit_action(new_state)
        new_state = self.submit_user.end_state
        self.password = self.get_type_password_action(new_state)
        self.submit = self.get_submit_action(new_state)

        if self.click_login is not None:
            actions.append(self.click_login)
        actions.append(self.click_login)
        actions.append(self.submit_user)
        actions.append(self.password)
        actions.append(self.submit)
        test = Test(name="Login Test %s" % self.url, actions=actions)
        test.save()
        return test
Exemple #2
0
    def test_save_action(self):
        element = ElementState(locators=[Locator(by=By.NAME, value="q")])
        element.save()
        google_home = State(url=self.driver.current_url, elements=[element])
        google_home.save()
        action = action_builder.get_nav_action("http://www.google.com/",
                                               google_home)
        action.save()

        state1 = State(elements=[element], url="http://www.google.com")
        state1.save()

        state2 = State(elements=[element], url="http://www.google.com")

        state2.save()
        commands = [
            Command(command=Command.NAVIGATE, params="http://www.google.com/"),
            Command(command=Command.SENDKEYS,
                    element=element,
                    params="Something")
        ]
        action = Action(name="Some Action",
                        steps=commands,
                        start_state=state1,
                        end_state=state2)
        action.save()
        state1.actions = [action]
        state1.save()
        print state1.id
        assert state1.actions[0].steps == commands
        assert state1.actions[0].end_state == state2
Exemple #3
0
 def generate_navigate_test(self, url):
     self.driver.get(url)
     end_state = state_builder.get_current_state(self.driver)
     end_state.save()
     action = action_builder.get_nav_action(url, end_state)
     action.save()
     action2 = action_builder.get_verify_state_action(end_state)
     action2.save()
     test = Test(name="Navigate %s Test" % url, actions=[action, action2])
     test.save()
     return test
Exemple #4
0
 def crawl_url(self, url):
     self.driver.get(url)
     initial_state = state_builder.get_current_state(self.driver)
     initial_state.save()
     blank_state = state_builder.get_blank_state()
     blank_state.save()
     nav_action = action_builder.get_nav_action(url, initial_state)
     nav_action.save()
     initial_state.init_actions = [nav_action]
     initial_state.save()
     print "Saved initial state %s" % initial_state.id
     return initial_state
Exemple #5
0
    def generate_login_test(self, url, username, password):
        self.driver.get(url)
        start_state = state_builder.get_current_state(self.driver)
        start_state.save()
        action = action_builder.get_nav_action(url, start_state)
        action.save()
        action2 = action_builder.get_login_action(self.driver, start_state,
                                                  username, password)
        action2.save()
        end_state = state_builder.get_current_state(self.driver)
        end_state.save()

        action3 = action_builder.get_verify_state_action(end_state)
        test = Test(name="Login Test %s" % url,
                    actions=[action, action2, action3])
        test.save()
        return test