diff --git a/examples/boilerplates/base_test_case.py b/examples/boilerplates/base_test_case.py index f7c87fe5..8f3f629e 100755 --- a/examples/boilerplates/base_test_case.py +++ b/examples/boilerplates/base_test_case.py @@ -18,15 +18,14 @@ class BaseTestCase(BaseCase): # Add custom tearDown code for your tests BEFORE the super().tearDown() super(BaseTestCase, self).tearDown() - def login_to_site(self): - # <<< Placeholder for actual code. Add your code here. >>> - # Add frequently used methods like this in your base test case class. - # This reduces the amount of duplicated code in your tests. - # If the UI changes, the fix only needs to be applied in one place. + def login(self): + # <<< Placeholder. Add your code here. >>> + # Reduce duplicate code in tests by having reusable methods like this. + # If the UI changes, the fix can be applied in one place. pass def example_method(self): - # <<< Placeholder for actual code. Add your code here. >>> + # <<< Placeholder. Add your code here. >>> pass @@ -38,6 +37,6 @@ from base_test_case import BaseTestCase class MyTests(BaseTestCase): def test_example(self): - self.login_to_site() + self.login() self.example_method() ''' diff --git a/examples/boilerplates/boilerplate_test.py b/examples/boilerplates/boilerplate_test.py index 862ccece..25d59c38 100755 --- a/examples/boilerplates/boilerplate_test.py +++ b/examples/boilerplates/boilerplate_test.py @@ -1,10 +1,10 @@ from .base_test_case import BaseTestCase -from .page_objects import HomePage +from .page_objects import Page class MyTestClass(BaseTestCase): def test_boilerplate(self): - self.login_to_site() + self.login() self.example_method() - self.assert_element(HomePage.html) + self.assert_element(Page.html) diff --git a/examples/boilerplates/page_objects.py b/examples/boilerplates/page_objects.py index 3fea9c37..a91b123d 100755 --- a/examples/boilerplates/page_objects.py +++ b/examples/boilerplates/page_objects.py @@ -1,17 +1,21 @@ ''' -Example of using the Page Object Model (POM) for tests, using page selectors. +Example of using the Page Object Pattern for tests, using CSS selectors. Helps make your code more Readable, Maintainable, and Reusable. Import a file like this at the top of your test files. ''' -class HomePage(object): +class Page(object): html = "html" ok_button = "#ok" cancel_button = "#cancel" see_items_button = "button.items" +class HomePage(object): + see_items_button = "button.items" + + class ShoppingPage(object): buyable_item = 'img[alt="Item"]' add_to_cart = "button.add" @@ -33,7 +37,7 @@ from .page_objects import HomePage, ShoppingPage, CheckoutPage class MyTests(BaseTestCase): def test_example(self): - self.login_to_site() + self.login() self.click(HomePage.see_items_button) self.click(ShoppingPage.buyable_item) self.click(ShoppingPage.add_to_cart)