Ejemplo n.º 1
0
    def test_local_suite(self):
        element = ElementState(locators=[Locator(by=By.NAME, value="q")])
        element.save()
        state1 = State(elements=[], url="")
        state2 = State(elements=[element], url="http://www.google.com")
        state1.save()
        state2.save()
        params = {}
        params["url"] = "http://www.google.com/"
        params["search"] = "Something"
        commands = [
            Command(command=Command.NAVIGATE, config_key="url"),
            Command(command=Command.SENDKEYS,
                    element=element,
                    config_key="search")
        ]
        action = Action(name="Some Action",
                        steps=commands,
                        start_state=state1,
                        end_state=state2)
        action.save()
        test = Test(name="Some test", actions=[action])
        test.save()
        suite = TestSuite(tests=[test], url="http://www.google.com/")

        config1 = RunConfig(browser="Firefox", params=params)
        config2 = RunConfig(browser="Chrome", params=params)
        configs = SuiteConfig(configs=[config1, config2], suite=suite)
        configs.save()
        suite.suite_config = configs
        suite.save()
        executor = SuiteExecutor(suite)
        executor.execute()
Ejemplo n.º 2
0
 def test_suite_config(self):
     params = {"url": "http://www.google.com/", "search": "Something"}
     suite = Suite.objects().first()
     config1 = RunConfig(browser="Firefox", params=params)
     config2 = RunConfig(browser="Chrome", params=params)
     suite_config = SuiteConfig(configs=[config1, config2],
                                suite=suite,
                                params=params)
     suite_config.save()
Ejemplo n.º 3
0
    def generate_suite(self, url):
        suite = Suite(url=url,name="Generated Navigation Suite")
        suite_config = SuiteConfig(suite=suite)
        for config in self.configs:
            params = {"url":url}
            config.params = params
            suite_config.configs.append(config)
            session = BrowserSession(config)
            session.start_session()
            self.driver = session.driver
            generator = TestGenerator(self.driver)
            test = generator.generate_navigate_test(url)
            suite.tests.append(test)

        suite_config.save()
        suite.suite_config = suite_config
        suite.save()
        session.end()
        return suite
Ejemplo n.º 4
0
    def test_sauce_suite(self):
        element = ElementState(locators=[Locator(by=By.NAME, value="q")])
        element.save()
        state1 = State(elements=[], url="")
        state2 = State(elements=[element], url="http://www.google.com")
        state1.save()
        state2.save()
        params = {}
        params["url"] = "http://www.google.com/"
        params["search"] = "Something"
        commands = [
            Command(command=Command.NAVIGATE, config_key="url"),
            Command(command=Command.SENDKEYS,
                    element=element,
                    config_key="search")
        ]
        action = Action(name="Some Action",
                        steps=commands,
                        start_state=state1,
                        end_state=state2)
        action.save()
        test = Test(name="Some test", actions=[action])
        test.save()
        suite = TestSuite(tests=[test], url="http://www.google.com/")

        config1 = RunConfig(browser="iphone",
                            sauce_user="******",
                            host="sauce",
                            sauce_key="c479e821-57e7-4b3f-8548-48e520585187",
                            params=params)
        config2 = RunConfig(browser="ipad",
                            sauce_user="******",
                            shost="sauce",
                            auce_key="c479e821-57e7-4b3f-8548-48e520585187",
                            params=params)
        configs = SuiteConfig(configs=[config1], suite=suite)
        configs.save()
        suite.suite_config = configs
        suite.save()
        executor = SuiteExecutor(suite)
        executor.execute()
Ejemplo n.º 5
0
    def test_compare_state(self):
        self.driver.get("http://www.google.com/")
        state1 = state_builder.get_blank_state()
        state1.save()
        state2 = state_builder.get_current_state(self.driver)
        state2.save()
        self.driver.get("https://www.google.com/#q=something")
        state3 = state_builder.get_current_state(self.driver)
        state3.save()
        config = RunConfig(params={
            "url": "http://www.google.com/",
            "search": "Something"
        })
        search_fields = element_filter.filter_contains_text(
            state2.elements, "Search")
        search_field = search_fields[0]
        commands1 = [Command(command=Command.NAVIGATE, config_key="url")]
        commands2 = [
            Command(command=Command.SENDKEYS,
                    element=search_field,
                    config_key="search")
        ]
        nav_action = Action(name="Google Nav",
                            steps=commands1,
                            start_state=state1,
                            end_state=state2)
        search_action = Action(name="Google Search",
                               steps=commands2,
                               start_state=state2,
                               end_state=state3)
        nav_action.save()
        search_action.save()
        test = Test(name="Google Search Failure",
                    actions=[nav_action, search_action])
        test.save()
        suite = Suite(name="Failure Example", tests=[test])
        suite.execute(self.driver, config)
        suite.save(cascade=True)
        print suite.id
        assert suite.suite_results[-1].passed

        search_field.locators = [Locator(by=By.CLASS_NAME, value="INVALID")]
        search_field.save()
        suite.execute(self.driver, config=config)
        results = suite.suite_results[-1]
        assert not results.passed

        comparison = StateComparer(self.driver).compare_states(
            results.failed_state, results.actual_state)

        assert len(comparison[0].elements) == len(comparison[1].elements)
Ejemplo n.º 6
0
 def test_save_test(self):
     element = ElementState(locators=[Locator(by=By.NAME, value="q")])
     element.save()
     state1 = State(elements=[], url="")
     state2 = State(elements=[element], url="http://www.google.com")
     state1.save()
     state2.save()
     config = RunConfig(params={
         "url": "http://www.google.com/",
         "search": "Something"
     })
     commands = [
         Command(command=Command.NAVIGATE, config_key="url"),
         Command(command=Command.SENDKEYS,
                 element=element,
                 config_key="search")
     ]
     action = Action(name="Some Action",
                     steps=commands,
                     start_state=state1,
                     end_state=state2)
     action.save()
     test = Test(name="Some test", actions=[action])
     test.save()
     suite = Suite(tests=[test], url="http://www.google.com/")
     suite.execute(self.driver, config)
     suite.save()
     assert suite.suite_results[-1].passed, suite.suite_results[-1].message
Ejemplo n.º 7
0
 def test_failure_report(self):
     element = ElementState(locators=[Locator(by=By.NAME, value="INVALID")])
     element2 = ElementState(
         locators=[Locator(by=By.NAME, value="INVALID")])
     element.save()
     element2.save()
     state1 = State(elements=[], url="")
     state2 = State(elements=[element], url="http://www.google.com")
     state3 = State(elements=[element2], url="http://www.google.com")
     state1.save()
     state2.save()
     state3.save()
     commands = [
         Command(command=Command.NAVIGATE,
                 config_key="http://www.google.com/"),
         Command(command=Command.SENDKEYS,
                 element=element,
                 config_key="search"),
         Command(command=Command.CLICK, element=element2)
     ]
     action = Action(name="Google Search",
                     steps=commands,
                     start_state=state1,
                     end_state=state3)
     action.save()
     test = Test(name="Some test", actions=[action])
     test.save()
     suite = Suite(name="some name", tests=[test])
     suite.execute(self.driver,
                   config=RunConfig(params={
                       "url": "http://www.google.com/",
                       "search": "Something"
                   }))
     suite.save()
     assert not suite.suite_results[-1].passed
     assert suite.suite_results[-1].actual_state is not None
     assert suite.suite_results[-1].failed_state is not None
     assert suite.suite_results[-1].html is not None and not ""
     assert suite.suite_results[-1].screenshot is not None and not ""