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 / check-for-error
Created November 11, 2011 19:04
check-for-error
(defn check-for-error
"Gets any notification and checks if error, if not error, does
nothing. If error throws exception."
(let [notif (notification)
msg (:msg notif)]
(cond (
(defn check-for-error
[ & [timeout]]
(try+ (check-for-success timeout)
(catch ::no-success-message-error _ nil)))
(defn extract-left-pane-list [loc]
(let [elems (for [index (iterate inc 1)]
(loc (str index)))
;(locators/left-pane-field-list (str index)))
retrieve (fn [elem]
(try (browser getText elem)
(catch Exception e nil)))]
(->> (map retrieve elems) (take-while identity) set)))
@els-pnw
els-pnw / pagessystems.py
Created January 13, 2012 15:44
Troubleshooting iteration over elements
def find_system_by_name(self):
locator = (By.XPATH, "//div[@class='one-line-ellipsis']")
systems_in_list = [element.text for element in self.selenium.find_elements(*locator)]
return systems_in_list
@els-pnw
els-pnw / Element details
Created January 13, 2012 19:14
troubleshooting name not found exception.
<div id="system_97" class="block tall" data-ajax_url="/headpin/systems/97/edit" style="width: 358px;">
<div>
<div class="column_2">
<div class="product">
<div class="one-line-ellipsis" style="padding-top: 2px;"> newsystem2820 </div>
</div>
<div class="column_2"> Never checked in. </div>
</div>
<div>
<div class="arrow-right"></div>
@els-pnw
els-pnw / pagessystems.py
Created January 16, 2012 16:31
Proposed change to systems.py
_system_list_locator = (By.CSS_SELECTOR, "div.block.tall")
def create_new_virt_system(self, system_name):
''' Create a new system '''
new_system_link_locator = self.selenium.find_element(*self._systems_create_new_locator)
ActionChains(self.selenium).move_to_element(new_system_link_locator).\
click().perform()
system_name_locator = self.selenium.find_element(*self._new_systemname_field_locator)
system_name_locator.send_keys(system_name)
@els-pnw
els-pnw / pagessystems.py
Created January 16, 2012 18:38
Troubleshooting explicit wait
save_button_locator = self.selenium.find_element(*self._new_system_save_locator)
ActionChains(self.selenium).move_to_element(save_button_locator).\
click().perform()
WebDriverWait(self.selenium, 20).until(lambda s: len(self.systems) > 0)
@els-pnw
els-pnw / base.py
Created January 17, 2012 19:55
troubleshooting long .click() delay.
def is_successful(self):
return self.is_element_present(*self._success_notification_locator)
@property
def is_failed(self):
return self.is_element_present(*self._error_notification_locator)
@els-pnw
els-pnw / blah.py
Created January 26, 2012 00:22
Troubleshooting Python ReST register system
#!/usr/bin/env python
import base64
import httplib
import urllib
try:
import json
except ImportError:
import simplejson as json
@els-pnw
els-pnw / restfultest.py
Created January 26, 2012 13:51
trying out ReST
#!/usr/bin/env python
import base64
import httplib
import urllib
import locale
import os
import mimetypes
try: