Skip to content

Instantly share code, notes, and snippets.

@weissjeffm
Created March 18, 2014 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weissjeffm/9620778 to your computer and use it in GitHub Desktop.
Save weissjeffm/9620778 to your computer and use it in GitHub Desktop.
getattr
class Region(object):
"""
Base class for all UI regions/pages
Args:
locators: A dict of locator objects for the given region
title: A string containing the title of the page
identifying_loc: Not sure
Usage:
page = Region(locators={
'configuration_button': (By.CSS_SELECTOR, "div.dhx_toolbar_btn[title='Configuration']"),
'discover_button': (By.CSS_SELECTOR,
"tr[title='Discover Cloud Providers']>td.td_btn_txt>" "div.btn_sel_text")
},
title='CloudForms Management Engine: Cloud Providers'
)
The elements can then accessed like so::
page.configuration_button
Locator attributes will return the locator tuple for that particular element,
and can be passed on to other functions, such as :py:func:`element` and :py:func:`click`.
"""
def __getattr__(self, name):
<<<<<<< HEAD
try:
return self.locators[name]
except KeyError:
return object.__getattribute__(self, name)
=======
if hasattr(self, 'locators'):
return self.locators[name]
else:
raise AttributeError("Region has no attribute named " + name)
>>>>>>> Create catalog is working
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment