Created
March 18, 2014 14:08
-
-
Save weissjeffm/9620778 to your computer and use it in GitHub Desktop.
getattr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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