Exemplo n.º 1
0
    def test_load_multiple_page_objects(
        self, get_context_mock, get_library_instance_mock
    ):
        """Verify that we can import multiple page objects, but only one is visible at a time

        This test is based on the current design of only allowing a
        single page object to be active at a time. That might change
        in the future - we might end up having page objects be pushed
        on a stack.

        """
        po = PageObjects(FOO_PATH, BAR_PATH)

        # Until we request the page object, we shouldn't be able to
        # see any keywords except the core page object keywords
        self.assertEqual(po.get_keyword_names(), CORE_KEYWORDS)

        # now load the "Foo" page object and verify only the Foo keyword
        # shows up and is callable.
        po.load_page_object("Test", "Foo")
        self.assertEqual(po.get_keyword_names(), CORE_KEYWORDS + ["foo_keyword_1"])
        self.assertEqual(po.foo_keyword_1("hello"), "foo keyword 1: hello")

        # now load the "Bar" page object and verify only the Bar keyword
        # shows up and is callable.
        po.load_page_object("Test", "Bar")
        self.assertEqual(
            po.get_keyword_names(), CORE_KEYWORDS + ["bar_keyword_1", "bar_keyword_2"]
        )
        self.assertEqual(po.bar_keyword_1("hello"), "bar keyword 1: hello")
Exemplo n.º 2
0
    def test_load_single_page_object(self, get_context_mock, get_library_instance_mock):
        """Verify that we don't see page object keywords until they are explicitly requested"""

        po = PageObjects(FOO_PATH)

        # Until we request the page object, we shouldn't be able to
        # see the page-specific keywords
        self.assertEqual(po.get_keyword_names(), CORE_KEYWORDS)

        # Now load the page object and verify the Foo keyword shows up
        po.load_page_object("Test", "Foo")
        self.assertEqual(po.get_keyword_names(), CORE_KEYWORDS + ["foo_keyword_1"])
Exemplo n.º 3
0
    def test_PageObject(self, get_context_mock, get_library_instance_mock):
        po = PageObjects()
        self.assertEqual(po.get_keyword_names(), CORE_KEYWORDS)
        self.assertEqual(po.registry, {})

        po = PageObjects(FOO_PATH, BAR_PATH)
        if hasattr(self, "assertCountEqual"):
            self.assertCountEqual(po.registry.keys(),
                                  (("Test", "Foo__c"), ("Test", "Bar__c")))
        else:
            # gah! python3 renamed this assert
            self.assertItemsEqual(po.registry.keys(),
                                  (("Test", "Foo__c"), ("Test", "Bar__c")))

        # The page object class will have been imported by robot.utils.Importer,
        # so we need to use that here to validate which class got imported.
        FooTestPage = importer.import_class_or_module_by_path(FOO_PATH)
        BarTestPage = importer.import_class_or_module_by_path(BAR_PATH)
        self.assertEqual(po.registry[("Test", "Foo__c")], FooTestPage)
        self.assertEqual(po.registry[("Test", "Bar__c")], BarTestPage)
Exemplo n.º 4
0
 def test_PageObject(self, get_context_mock, get_library_instance_mock):
     """Smoke test to make sure the default registry is set up and keywords exist"""
     po = PageObjects()
     self.assertEqual(po.get_keyword_names(), CORE_KEYWORDS)
     self.assertEqual(po.registry, BASE_REGISTRY)
Exemplo n.º 5
0
 def test_PageObject(self, get_context_mock, get_library_instance_mock):
     po = PageObjects()
     # no page objects loaded, so get_keyword_names should only return
     # the core keywords
     self.assertEqual(po.get_keyword_names(), CORE_KEYWORDS)
     self.assertEqual(po.registry, {})