Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adds select_option function for drop down select elements

  • Loading branch information...
commit b81bc92ce0df0e96a9abb0beef216364f50a7853 1 parent 9210d55
@casschin casschin authored
Showing with 12 additions and 9 deletions.
  1. +12 −9 pages/page.py
View
21 pages/page.py
@@ -54,6 +54,18 @@ def refresh(self):
def open(self, url_fragment):
self.selenium.get(self.base_url + url_fragment)
+ def select_option(self, value, locator):
+ dropdown = self.selenium.find_element(*locator)
+ option_found = False
+ all_options = dropdown.find_elements_by_tag_name("option")
+ for option in all_options:
+ if option.get_attribute("value") == value:
+ option_found = True
+ option.click()
+ break
+ if option_found is False:
+ raise Exception("Option '" + value + "' was not found, thus not selectable.")
+
def is_element_present(self, *locator):
self.selenium.implicitly_wait(0)
try:
@@ -97,12 +109,3 @@ def wait_for_ajax(self):
if self.selenium.execute_script("return jQuery.active == 0"):
return
raise Exception("Wait for AJAX timed out after %s seconds" % count)
-
- def get_response_code(self, url):
- # return the response status
- requests_config = {'max_retries': 5}
- try:
- r = requests.head(url, verify=False, allow_redirects=True, config=requests_config, timeout=self.timeout)
- return r.status_code
- except Timeout:
- return 408
Please sign in to comment.
Something went wrong with that request. Please try again.