summaryrefslogtreecommitdiff
path: root/service/test/functional
diff options
context:
space:
mode:
authorTulio Casagrande <tcasagra@thoughtworks.com>2016-11-30 19:07:56 -0200
committerTulio Casagrande <tcasagra@thoughtworks.com>2016-11-30 19:07:56 -0200
commita8a7362054f4b49ea1fbc00fe7b556e6e6ea4590 (patch)
tree3151988160ca29e6dfede48b160c44e48d72f8a0 /service/test/functional
parentb6f60fd007efc84ef7cc2b63988448a61bbeb8d2 (diff)
Add timeout to find by css selector
See: https://github.com/pixelated/project-issues/issues/381
Diffstat (limited to 'service/test/functional')
-rw-r--r--service/test/functional/features/steps/common.py20
-rw-r--r--service/test/functional/features/steps/signup.py4
2 files changed, 9 insertions, 15 deletions
diff --git a/service/test/functional/features/steps/common.py b/service/test/functional/features/steps/common.py
index c3916313..2fd2ec4f 100644
--- a/service/test/functional/features/steps/common.py
+++ b/service/test/functional/features/steps/common.py
@@ -66,15 +66,9 @@ def wait_until_elements_are_visible_by_locator(context, locator_tuple, timeout=T
return context.browser.find_elements(locator_tuple[0], locator_tuple[1])
-def wait_until_elements_are_visible_by_xpath(context, locator_tuple, timeout=TIMEOUT_IN_S):
- wait = WebDriverWait(context.browser, timeout)
- wait.until(EC.presence_of_all_elements_located(locator_tuple))
- return context.browser.find_elements(locator_tuple[0], locator_tuple[1])
-
-
def wait_until_element_is_visible_by_locator(context, locator_tuple, timeout=TIMEOUT_IN_S):
wait = WebDriverWait(context.browser, timeout)
- wait.until(EC.visibility_of_element_located(locator_tuple))
+ wait.until(EC.presence_of_element_located(locator_tuple))
return context.browser.find_element(locator_tuple[0], locator_tuple[1])
@@ -88,8 +82,8 @@ def fill_by_xpath(context, xpath, text):
field.send_keys(text)
-def fill_by_css_selector(context, css_selector, text):
- field = find_element_by_css_selector(context, css_selector)
+def fill_by_css_selector(context, css_selector, text, timeout=TIMEOUT_IN_S):
+ field = find_element_by_css_selector(context, css_selector, timeout=timeout)
field.send_keys(text)
@@ -118,8 +112,8 @@ def find_element_by_id(context, id):
return wait_until_element_is_visible_by_locator(context, (By.ID, id))
-def find_element_by_css_selector(context, css_selector):
- return wait_until_element_is_visible_by_locator(context, (By.CSS_SELECTOR, css_selector))
+def find_element_by_css_selector(context, css_selector, timeout=TIMEOUT_IN_S):
+ return wait_until_element_is_visible_by_locator(context, (By.CSS_SELECTOR, css_selector), timeout=timeout)
def find_element_by_class_name(context, class_name):
@@ -130,8 +124,8 @@ def find_elements_by_css_selector(context, css_selector, timeout=TIMEOUT_IN_S):
return wait_until_elements_are_visible_by_locator(context, (By.CSS_SELECTOR, css_selector), timeout=timeout)
-def find_elements_by_xpath(context, xpath):
- return wait_until_elements_are_visible_by_xpath(context, (By.XPATH, xpath))
+def find_elements_by_xpath(context, xpath, timeout=TIMEOUT_IN_S):
+ return wait_until_elements_are_visible_by_locator(context, (By.XPATH, xpath), timeout=timeout)
def find_element_containing_text(context, text, element_type='*'):
diff --git a/service/test/functional/features/steps/signup.py b/service/test/functional/features/steps/signup.py
index 1252017c..1558004b 100644
--- a/service/test/functional/features/steps/signup.py
+++ b/service/test/functional/features/steps/signup.py
@@ -18,6 +18,7 @@ import uuid
from behave import given, then, when
from common import (
+ element_should_have_content,
fill_by_css_selector,
find_element_by_css_selector)
@@ -41,5 +42,4 @@ def step_impl(context):
@then(u'I should see the user control panel') # noqa
def step_impl(context):
- text = find_element_by_css_selector(context, 'h1').text
- assert text == 'user control panel'
+ element_should_have_content(context, 'h1', 'user control panel')