diff --git a/PageObjectLibrary/__init__.py b/PageObjectLibrary/__init__.py index db5b4ef..748f774 100644 --- a/PageObjectLibrary/__init__.py +++ b/PageObjectLibrary/__init__.py @@ -1,8 +1,10 @@ from __future__ import absolute_import, unicode_literals + from .keywords import PageObjectLibraryKeywords from .pageobject import PageObject from .version import __version__ + class PageObjectLibrary(PageObjectLibraryKeywords): """This project is hosted on github in the repository @@ -142,7 +144,7 @@ class your keywords have access to the following pre-defined | ``*** Test Cases ***`` | Log in to the application | Go to page LoginPage - | Log in as a normal user + | Log in as a normal user | The current page should be DashboardPage """ diff --git a/PageObjectLibrary/keywords.py b/PageObjectLibrary/keywords.py index 13c2374..97e9886 100644 --- a/PageObjectLibrary/keywords.py +++ b/PageObjectLibrary/keywords.py @@ -7,15 +7,19 @@ """ from __future__ import print_function, absolute_import, unicode_literals -import six + import robot.api from robot.libraries.BuiltIn import BuiltIn + +import six + from .pageobject import PageObject try: from urlparse import urlparse except ImportError: from urllib.parse import urlparse + class PageObjectLibraryKeywords(object): ROBOT_LIBRARY_SCOPE = "TEST SUITE" @@ -69,7 +73,7 @@ def the_current_page_should_be(self, page_name): # If we get here, we're not on the page we think we're on raise Exception("Expected page to be %s but it was not" % page_name) - def go_to_page(self, page_name, page_root = None): + def go_to_page(self, page_name, page_root=None): """Go to the url for the given page object. Unless explicitly provided, the URL root will be based on the @@ -125,4 +129,3 @@ def _get_page_object(self, page_name): page = self.builtin.get_library_instance(page_name) return page - diff --git a/PageObjectLibrary/locatormap.py b/PageObjectLibrary/locatormap.py index 36bd7d8..08c48f7 100644 --- a/PageObjectLibrary/locatormap.py +++ b/PageObjectLibrary/locatormap.py @@ -1,6 +1,8 @@ from __future__ import absolute_import, unicode_literals + import six + class LocatorMap(dict): """LocatorMap - a dict-like object that supports dot notation diff --git a/PageObjectLibrary/pageobject.py b/PageObjectLibrary/pageobject.py index a819347..cb35114 100644 --- a/PageObjectLibrary/pageobject.py +++ b/PageObjectLibrary/pageobject.py @@ -1,21 +1,26 @@ from __future__ import absolute_import, unicode_literals + +from abc import ABCMeta +from contextlib import contextmanager + import robot.api from robot.libraries.BuiltIn import BuiltIn -from contextlib import contextmanager -from selenium.webdriver.support.ui import WebDriverWait + from selenium.webdriver.support.expected_conditions import staleness_of -from abc import ABCMeta +from selenium.webdriver.support.ui import WebDriverWait + import six from .locatormap import LocatorMap + class PageObject(six.with_metaclass(ABCMeta, object)): """Base class for page objects Classes that inherit from this class need to define the following class variables: - PAGE_TITLE the title of the page; used by the default + PAGE_TITLE the title of the page; used by the default implementation of _is_current_page PAGE_URL this should be the URL of the page, minus the hostname and port (eg: /loginpage.html) @@ -25,18 +30,18 @@ class PageObject(six.with_metaclass(ABCMeta, object)): provided by this class. It compares the current page title to the class variable PAGE_TITLE. A class can override this method if the page title is not unique or is indeterminate. - + Classes that inherit from this class have access to the following properties: * se2lib a reference to an instance of Selenium2Library * browser a reference to the current webdriver instance * logger a reference to robot.api.logger - * locator a wrapper around the page object's ``_locators`` dictionary + * locator a wrapper around the page object's ``_locators`` dictionary This class implements the following context managers: - * _wait_for_page_refresh + * _wait_for_page_refresh This context manager is designed to be used in page objects when a keyword should wait to return until the html element has been @@ -110,4 +115,3 @@ def _is_current_page(self): self.logger.info(" actual title: '%s'" % actual_title) raise Exception("expected title to be '%s' but it was '%s'" % (expected_title, actual_title)) return False - diff --git a/setup.py b/setup.py index 87e0924..db0b556 100644 --- a/setup.py +++ b/setup.py @@ -1,23 +1,27 @@ # N.B. to push a new version to PyPi, update the version number # in rfhub/version.py and then run 'python setup.py sdist upload' +import sys + from setuptools import setup -execfile('PageObjectLibrary/version.py') +from .version import __version__ + +exec(compile(open('PageObjectLibrary/version.py').read())) setup( - name = 'robotframework-pageobjectlibrary', - version = __version__, - author = 'Bryan Oakley', - author_email = 'bryan.oakley@gmail.com', - url = 'https://github.com/boakley/robotframework-pageobjectlibrary/', - keywords = 'robotframework', - license = 'Apache License 2.0', - description = 'RobotFramework library that implements the Page Object pattern', - long_description = open('README.md').read(), - zip_safe = True, - include_package_data = True, - install_requires = ['robotframework', 'robotframework-selenium2library', 'selenium', 'six'], - classifiers = [ + name='robotframework-pageobjectlibrary', + version=__version__, + author='Bryan Oakley', + author_email='bryan.oakley@gmail.com', + url='https://github.com/boakley/robotframework-pageobjectlibrary/', + keywords='robotframework', + license='Apache License 2.0', + description='RobotFramework library that implements the Page Object pattern', + long_description=open('README.md', encoding='latin-1').read(), + zip_safe=True, + include_package_data=True, + install_requires=['robotframework', 'robotframework-seleniumlibrary', 'selenium', 'six'], + classifiers=[ "Development Status :: 4 - Beta", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", @@ -27,8 +31,8 @@ "Topic :: Software Development :: Quality Assurance", "Intended Audience :: Developers", ], - packages =[ + packages=[ 'PageObjectLibrary', ], - scripts =[], + scripts=[], )