diff options
Diffstat (limited to 'services/frontend/base_actions')
-rw-r--r-- | services/frontend/base_actions/get.py | 22 | ||||
-rw-r--r-- | services/frontend/base_actions/wait.py | 19 |
2 files changed, 29 insertions, 12 deletions
diff --git a/services/frontend/base_actions/get.py b/services/frontend/base_actions/get.py index 8735c1b..5fb801a 100644 --- a/services/frontend/base_actions/get.py +++ b/services/frontend/base_actions/get.py @@ -1,5 +1,5 @@ - -# ============LICENSE_START========================================== + +# ============LICENSE_START========================================== # org.onap.vvp/test-engine # =================================================================== # Copyright © 2017 AT&T Intellectual Property. All rights reserved. @@ -37,6 +37,7 @@ # # ECOMP is a trademark and service mark of AT&T Intellectual Property. from services.frontend.base_actions.wait import Wait +from services.helper import Helper from services.session import session @@ -98,8 +99,10 @@ class Get: raise Exception(errorMsg, attr_name_value) @staticmethod - def value_by_name(attr_name_value): + def value_by_name(attr_name_value, wait_for_page=False): try: + if wait_for_page: + Wait.page_has_loaded() Wait.name(attr_name_value) return session.ice_driver.find_element_by_name(attr_name_value).get_attribute("value") except Exception as e: @@ -125,3 +128,16 @@ class Get: except Exception as e: errorMsg = "Failed to get if it's selected by id:" + attr_id_value raise Exception(errorMsg, attr_id_value) + + @staticmethod + def is_checkbox_selected_by_id(attr_id_value, wait_for_page=False): + try: + if wait_for_page: + Wait.page_has_loaded() + Wait.id(attr_id_value) + return Helper.internal_assert_boolean_true_false( + session.ice_driver.find_element_by_id( + attr_id_value).get_attribute("value"), "on") + except Exception as e: + errorMsg = "Failed to get if it's selected by id:" + attr_id_value + raise Exception(errorMsg, attr_id_value) diff --git a/services/frontend/base_actions/wait.py b/services/frontend/base_actions/wait.py index 50eff08..a699917 100644 --- a/services/frontend/base_actions/wait.py +++ b/services/frontend/base_actions/wait.py @@ -196,17 +196,18 @@ class Wait: @staticmethod def page_has_loaded(): - countwait_untilelement_to_be_presented_by_id = 0 for _ in range(Constants.FEConstants.RETRIES_NUMBER): - httpRequests = session.ice_driver.execute_script( - 'return window.angular ? window.angular.element("body").injector().get("$http").pendingRequests.length : 1;') - if(str(httpRequests) == "0"): + try: + httpRequests = session.ice_driver.execute_script( + 'return window.angular ? window.angular.element("body").injector().get("$http").pendingRequests.length : 1;') + if(str(httpRequests) == "0"): + time.sleep(session.wait_until_time_pause) + return + logger.debug( + "Checking if {} page is loaded. ".format(session.ice_driver.current_url)) time.sleep(session.wait_until_time_pause) - return - logger.debug( - "Checking if {} page is loaded. ".format(session.ice_driver.current_url)) - time.sleep(session.wait_until_time_pause) - countwait_untilelement_to_be_presented_by_id += 1 + except Exception as exception: + continue raise Exception("Page loading took too much time") |