Created
August 15, 2012 17:15
-
-
Save els-pnw/3361694 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
>>> $$('a.fl.clear') | |
[a.fl /headpin...org_id=1, a.fl /headpin...org_id=2] | |
---firebug copy html --- | |
<a title="ACME_Corporation" rel="nofollow" data-method="POST" class="fl clear" href="/headpin/user_session/set_org?org_id=1">ACME_Corporation</a> | |
<a title="Test" rel="nofollow" data-method="POST" class="fl clear" href="/headpin/user_session/set_org?org_id=2">Test</a> |
This file contains hidden or 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
--- from locators.py --- | |
login_org_selector = (By.CSS_SELECTOR, "div.jspPane") | |
login_org_dropdown = (By.CSS_SELECTOR, "div.one-line-ellipsis") | |
--- | |
def select_org(self, value): | |
""" | |
Select an org from the available orgs. | |
:param value: The org to look for, by text. | |
""" | |
self.click(*login_org_dropdown) | |
self.jquery_wait() | |
for org in self.selectable_orgs(): | |
if value in org.name: | |
return org | |
raise Exception('Organization not found: %s' % value) | |
def selectable_orgs(self): | |
""" | |
Iterate over the available orgs in the login org selector. | |
""" | |
return [self.LoginOrgSelector(self.testsetup, element) for element in self.selenium.find_elements(*login_org_selector)] | |
class LoginOrgSelector(Page): | |
_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() |
This file contains hidden or 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
<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> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment