Skip to content

Commit

Permalink
Initial changes to work on python 3 and cleaning up flake8 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Daron Andrew Edie committed Jul 16, 2018
1 parent cc242ed commit 603e563
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 28 deletions.
4 changes: 3 additions & 1 deletion PageObjectLibrary/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
"""
Expand Down
9 changes: 6 additions & 3 deletions PageObjectLibrary/keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -125,4 +129,3 @@ def _get_page_object(self, page_name):
page = self.builtin.get_library_instance(page_name)

return page

2 changes: 2 additions & 0 deletions PageObjectLibrary/locatormap.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
20 changes: 12 additions & 8 deletions PageObjectLibrary/pageobject.py
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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

36 changes: 20 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -27,8 +31,8 @@
"Topic :: Software Development :: Quality Assurance",
"Intended Audience :: Developers",
],
packages =[
packages=[
'PageObjectLibrary',
],
scripts =[],
scripts=[],
)

0 comments on commit 603e563

Please sign in to comment.