Skip to content

Instantly share code, notes, and snippets.

View els-pnw's full-sized avatar

Eric Sammons els-pnw

View GitHub Profile
@els-pnw
els-pnw / restfultest.py
Created January 26, 2012 14:25
working GET
#!/usr/bin/env python
import base64
import httplib
import urllib
import locale
import os
import mimetypes
try:
@els-pnw
els-pnw / pagesapi.py
Created January 26, 2012 20:21
Browser launches when not needed
...
def _GET(self, path, queries=(), customHeaders={}):
return self._request('GET', path, queries, customHeaders=customHeaders)
...
def ping(self, username='admin', password='admin'):
self.set_basic_auth_credentials(username, password)
path = "ping"
return self._GET(path)
@els-pnw
els-pnw / test_email.py
Created January 27, 2012 17:06
double_click() issue
def update_email_addr(self, new_email):
WebDriverWait(self.selenium, 120).until(lambda s: self.is_element_visible(*self._username_locator))
self.selenium.find_element(*self._edit_email_locator).click()
email_input_locator = self.selenium.find_element(*self._edit_email_locator)
ActionChains(self.selenium).move_to_element(email_input_locator).\
double_click().perform()
#new_email_locator = self.selenium.find_element(*self._edit_email_locator)
email_input_locator.send_keys(new_email+"\n")
@els-pnw
els-pnw / blah.py
Created January 27, 2012 21:47
issue with h1 check
def click_sam_h1(self):
try:
self.selenium.find_element(*self._sam_h1_locator).click()
return True
except:
throw ("The header element should be visible, it's not, do something!")
Assert.true(home_page.click_sam_h1)
def is_footer_version_text_visible(self):
return self.selenium.text(*self._footer_version_text_locator)
Assert.equal(home_page.is_footer_version_text_visible(), "Some Text")
def is_footer_version_text_visible(self):
#return self.selenium.find_elements_by_partial_link_text('Subscription Asset Manager Version')
return self.selenium.find_element(*self._footer_version_text_locator).text
Assert.equal(home_page.is_footer_version_text_visible(), "Some Text")
<div class="jspContainer" style="width: 249px; height: 220px;">
<div class="jspPane" style="padding: 10px 13px; top: 0px; width: 209px;">
<a class="fl clear" rel="nofollow" data-method="POST" href="/headpin/user_session/set_org?org_id=1" style="display: none;">ACME_Corporation</a>
<a class="fl clear" rel="nofollow" data-method="POST" href="/headpin/user_session/set_org?org_id=2" style="display: none;">Org-X2YVL8SkHqThajDS</a>
<a class="fl clear" rel="nofollow" data-method="POST" href="/headpin/user_session/set_org?org_id=3" style="display: none;">Org-YL3P08ydJPNWz</a>
<a class="fl clear" rel="nofollow" data-method="POST" href="/headpin/user_session/set_org?org_id=4">SearchOrg-Vz2xIOuhX</a>
<a class="fl clear" rel="nofollow" data-method="POST" href="/headpin/user_session/set_org?org_id=5" style="display: none;">SearchOrg-ILDUWvvop</a>
<a class="fl clear" rel="nofollow" data-method="POST" href="/headpin/user_session/set_org?org_id=6" style="display: none;">SearchOrg-yb5bERhPPC</a>
<a class="fl clear" rel="nofol
def click_filtered_result(self, criteria):
_org_filtered_result_locator = (By.XPATH, "//a[contains(text(), '" + criteria + "')]")
#filtered_result_locator = self.selenium.find_element(*self._org_filtered_result_locator)
#ActionChains(self.selenium).move_to_element(filtered_result_locator).\
# click().perform()
#WebDriverWait(self.selenium, 30).until(lambda s: self.is_element_visible(*self._org_filtered_result_locator))
self.selenium.find_element(*self._org_filtered_result_locator).click()
_subscriptions_checkbox_locator = (By.XPATH, "//input[@type='checkbox']")
def select_subscription(self):
subs = self.selenium.find_elements(*self._subscriptions_checkbox_locator)
a_sub = choice(subs)
print subs
print a_sub
#self.selenium.find_element(a_sub).click()
a_sub_locator = self.selenium.find_element(*a_sub)
ActionChains(self.selenium).move_to_element(a_sub_locator).\
<div class="actions">
<input id="subscription_submit_button" class="submit dialogbutton" type="submit" value="Add to Key" style="display:none;" name="commit">
<a id="fake_subscription_submit_button" class="dialogbutton button disabled">Add to Key</a>
</div>
_available_subscriptions_submit_locator = (By.XPATH, "//input[@id='subscription_submit_button']")
def click_submit_key(self):
#WebDriverWait(self.selenium, 10).until(lambda s: self.is_element_visible(*self._available_subscriptions_submit_locator))