Ejemplo n.º 1
0
 def test_to(self):
     agent = Agent(self.driver)
     agent.to(DuckDuckGoPage)
     self.assertNotEqual(self.driver.current_url, CSSTestPage.url)
     agent.to(CSSTestPage)
     # have to split on final directory as chrome has file:/// instead of file://// (like firefox and phantomjs)
     self.assertTrue(self.driver.current_url.split('fixtures/')[1].endswith(CSSTestPage.url.split('fixtures/')[1]))
Ejemplo n.º 2
0
 def test_wait_timeout(self):
     agent = Agent(self.driver)
     DuckDuckGoPage.wait = 1
     DuckDuckGoPage.title = "Incorrect title to trigger exception"
     agent.to(DuckDuckGoPage)
     try:
         agent.at(DuckDuckGoPage)
         self.fail("Didn't raise Exception")
     except NotAtPageException, e:
         pass
Ejemplo n.º 3
0
 def test_at_raises_exception_if_not_at_correct_page(self):
     agent = Agent(self.driver)
     agent.to(DuckDuckGoPage)
     try:
         agent.at(UnknownTestPage)
         self.fail("Didn't raise Exception")
     except NotAtPageException, e:
         self.assertEquals(
             'Not at correct page. Expected "unknown" but found "Search DuckDuckGo"',
             e.message
         )
Ejemplo n.º 4
0
    def test_do_calls_callable_correctly(self):
        agent = Agent(self.driver)
        agent.foo = 0

        def my_func(page):
            agent.foo = 1
        CSSTestPage.wait = 5
        agent.to_at(CSSTestPage)
        agent.then(my_func)
        self.assertEquals(agent.foo, 1)
Ejemplo n.º 5
0
class TestCaseHorace(TestCase):
    def setUp(self):
        agentDriver = Driver({"driver": getenv("BROWSER", "phantomjs"), "platform": getenv("PLATFORM", "ANY")})
        self.agent = Agent(agentDriver)

    def tearDown(self):
        self.agent.close()

    def to(self, page, path=None, parameters=None):
        self.agent.to(page, path, parameters)

    def at(self, page):
        self.agent.at(page)

    def to_at(self, page, path=None, parameters=None):
        self.agent.to_at(page, path, parameters)

    def __getattr__(self, item):
        if item == "page":
            return self.agent.page
        elif item == "_driver":
            return self.agent._driver
        else:
            return object.__getattribute__(self, item)
Ejemplo n.º 6
0
 def setUp(self):
     agentDriver = Driver({"driver": getenv("BROWSER", "phantomjs"), "platform": getenv("PLATFORM", "ANY")})
     self.agent = Agent(agentDriver)
Ejemplo n.º 7
0
 def test_do_does_not_call_an_uncallable(self):
     agent = Agent(self.driver)
     agent.foo = 0
     agent.to_at(CSSTestPage)
     agent.then(1)
     self.assertEquals(agent.foo, 0)
Ejemplo n.º 8
0
 def test_currentPage(self):
     agent = Agent(self.driver)
     agent.to_at(DuckDuckGoPage)
     self.assertIsInstance(agent.page, DuckDuckGoPage)
Ejemplo n.º 9
0
 def test_toAt(self):
     agent = Agent(self.driver)
     agent.to_at(DuckDuckGoPage)
     self.assertTrue(DuckDuckGoPage.title, self.driver.title)
Ejemplo n.º 10
0
 def test_at(self):
     agent = Agent(self.driver)
     agent.to(DuckDuckGoPage)
     agent.at(DuckDuckGoPage)
     self.assertEquals(DuckDuckGoPage.title, self.driver.title)