Skip to content

Instantly share code, notes, and snippets.

@adamgoucher
Created June 18, 2013 04:01
Show Gist options
  • Save adamgoucher/5802604 to your computer and use it in GitHub Desktop.
Save adamgoucher/5802604 to your computer and use it in GitHub Desktop.
A taste of what our webinar has in store for you
def menu(self, path):
chain = ActionChains(self.driver)
split_path = path.split('/')
for p in split_path:
# go back up?
if p == '..':
chain.send_keys_to_element(self._current_menu_item, Keys.ARROW_LEFT)
else:
e = self.driver.find_element(*locators[p.lower()])
# these are downloads
href = e.get_attribute('href')
ext = href[href.rfind('.') + 1:]
if ext in ['pdf', 'csv', 'xls']:
chain.move_to_element(e)
# jquery disabled
elif 'ui-state-disabled' in self.driver.execute_script('return arguments[0].parentNode.getAttribute("class");', e):
chain.move_to_element(e)
else:
chain.click(e)
chain.perform()
self._current_menu_item = e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment