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()
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
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()