Skip to content

Instantly share code, notes, and snippets.

@els-pnw
Created August 15, 2012 13:49
Show Gist options
  • Save els-pnw/3360310 to your computer and use it in GitHub Desktop.
Save els-pnw/3360310 to your computer and use it in GitHub Desktop.
source
---- from locators.py ----
login_org_selector = (By.CSS_SELECTOR, "a.fl")
login_org_dropdown = (By.CSS_SELECTOR, "div.one-line-ellipsis")
----
def select_org(self, value='ACME_Corporation'):
self.click(*login_org_dropdown)
time.sleep(2)
for org in self.selectable_orgs:
if value in org.name:
return org
raise Exception('Organization not found: %s' % value)
def selectable_orgs(self):
return [self.LoginOrgSelector(self.testsetup, element) for element in self.selenium.find_elements(*login_org_selector)]
class LoginOrgSelector(Base):
_name_locator = (By.CSS_SELECTOR, 'a.fl.clear')
def __init__(self, testsetup, element):
Page.__init__(self, testsetup)
self._root_element = element
@property
def name(self):
name_text = self._root_element.find_element(*self._name_locator).text
return name_text
@property
def is_displayed(self):
return self.is_element_visible(*self._name_locator)
def click(self):
self._root_element.find_element(*self._name_locator).click()
<div id="switcherContainer" class="clickable active">
<a id="switcherButton" class="active" title="">
<div class="one-line-ellipsis"> Select an Organization: </div>
<div class="arrow_icon_menu"></div>
</a>
<div id="switcherBox" style="display: block;">
<div id="switcherForm" class="org">
<div id="orgfilter">
<div id="orgbox" data-url="/headpin/user_session/allowed_orgs" style="overflow: hidden; padding: 0px; width: 300px;">
<div class="jspContainer" style="width: 300px; height: 100px;">
<div class="jspPane" style="padding: 0px; top: 0px; width: 300px;">
<a class="fl clear" title="ACME_Corporation" rel="nofollow" data-method="POST" href="/headpin/user_session/set_org?org_id=1">ACME_Corporation</a>
<a class="fl clear" title="Test" rel="nofollow" data-method="POST" href="/headpin/user_session/set_org?org_id=2">Test</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment