aboutsummaryrefslogtreecommitdiffstats
path: root/services/frontend/base_actions
diff options
context:
space:
mode:
Diffstat (limited to 'services/frontend/base_actions')
-rw-r--r--services/frontend/base_actions/__init__.py38
-rw-r--r--services/frontend/base_actions/__pycache__/__init__.cpython-36.pycbin0 -> 158 bytes
-rw-r--r--services/frontend/base_actions/__pycache__/click.cpython-36.pycbin0 -> 2607 bytes
-rw-r--r--services/frontend/base_actions/__pycache__/enter.cpython-36.pycbin0 -> 3741 bytes
-rw-r--r--services/frontend/base_actions/__pycache__/get.cpython-36.pycbin0 -> 3014 bytes
-rw-r--r--services/frontend/base_actions/__pycache__/wait.cpython-36.pycbin0 -> 6396 bytes
-rw-r--r--services/frontend/base_actions/click.py108
-rw-r--r--services/frontend/base_actions/enter.py139
-rw-r--r--services/frontend/base_actions/get.py127
-rw-r--r--services/frontend/base_actions/wait.py317
10 files changed, 729 insertions, 0 deletions
diff --git a/services/frontend/base_actions/__init__.py b/services/frontend/base_actions/__init__.py
new file mode 100644
index 0000000..30d7152
--- /dev/null
+++ b/services/frontend/base_actions/__init__.py
@@ -0,0 +1,38 @@
+
+# ============LICENSE_START==========================================
+# org.onap.vvp/test-engine
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the “License”);
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
diff --git a/services/frontend/base_actions/__pycache__/__init__.cpython-36.pyc b/services/frontend/base_actions/__pycache__/__init__.cpython-36.pyc
new file mode 100644
index 0000000..567e40e
--- /dev/null
+++ b/services/frontend/base_actions/__pycache__/__init__.cpython-36.pyc
Binary files differ
diff --git a/services/frontend/base_actions/__pycache__/click.cpython-36.pyc b/services/frontend/base_actions/__pycache__/click.cpython-36.pyc
new file mode 100644
index 0000000..7848aff
--- /dev/null
+++ b/services/frontend/base_actions/__pycache__/click.cpython-36.pyc
Binary files differ
diff --git a/services/frontend/base_actions/__pycache__/enter.cpython-36.pyc b/services/frontend/base_actions/__pycache__/enter.cpython-36.pyc
new file mode 100644
index 0000000..df5e175
--- /dev/null
+++ b/services/frontend/base_actions/__pycache__/enter.cpython-36.pyc
Binary files differ
diff --git a/services/frontend/base_actions/__pycache__/get.cpython-36.pyc b/services/frontend/base_actions/__pycache__/get.cpython-36.pyc
new file mode 100644
index 0000000..a95dc14
--- /dev/null
+++ b/services/frontend/base_actions/__pycache__/get.cpython-36.pyc
Binary files differ
diff --git a/services/frontend/base_actions/__pycache__/wait.cpython-36.pyc b/services/frontend/base_actions/__pycache__/wait.cpython-36.pyc
new file mode 100644
index 0000000..29b73ba
--- /dev/null
+++ b/services/frontend/base_actions/__pycache__/wait.cpython-36.pyc
Binary files differ
diff --git a/services/frontend/base_actions/click.py b/services/frontend/base_actions/click.py
new file mode 100644
index 0000000..00470b7
--- /dev/null
+++ b/services/frontend/base_actions/click.py
@@ -0,0 +1,108 @@
+
+# ============LICENSE_START==========================================
+# org.onap.vvp/test-engine
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the “License”);
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+from selenium.webdriver.common.action_chains import ActionChains
+
+from services.frontend.base_actions.wait import Wait
+from services.session import session
+
+
+class Click:
+
+ @staticmethod
+ def id(element_id, wait_for_page=False):
+ try:
+ if wait_for_page:
+ Wait.page_has_loaded()
+ Wait.id(element_id)
+ session.ice_driver.find_element_by_id(element_id).click()
+ except Exception as e: # If failed - count the failure and add the error to list of errors.
+ errorMsg = "Failed to click_on on ID " + element_id
+ raise Exception(errorMsg, e)
+
+ @staticmethod
+ def name(element_name, wait_for_page=False):
+ try:
+ if wait_for_page:
+ Wait.page_has_loaded()
+ Wait.name(element_name)
+ session.ice_driver.find_element_by_name(element_name).click()
+ except Exception as e: # If failed - count the failure and add the error to list of errors.
+ errorMsg = "Failed to click_on on ID " + element_name
+ raise Exception(errorMsg, e)
+
+ @staticmethod
+ def link_text(link_inner_text, wait_for_page=False):
+ try:
+ if wait_for_page:
+ Wait.page_has_loaded()
+ Wait.link_text(link_inner_text)
+ session.ice_driver.find_element_by_link_text(link_inner_text).click()
+ except Exception as e: # If failed - count the failure and add the error to list of errors.
+ errorMsg = "Failed to click_on on LINK TEXT " + link_inner_text
+ raise Exception(errorMsg, e)
+
+ @staticmethod
+ def css(element_css, wait_for_page=False):
+ try:
+ if wait_for_page:
+ Wait.page_has_loaded()
+ Wait.css(element_css)
+ session.ice_driver.find_element_by_css_selector(element_css).click()
+ except Exception as e: # If failed - count the failure and add the error to list of errors.
+ errorMsg = "Failed to click_on on CSS Selector " + element_css
+ raise Exception(errorMsg, e)
+
+ @staticmethod
+ def xpath(element_xpath, wait_for_page=False):
+ try:
+ if wait_for_page:
+ Wait.page_has_loaded()
+ Wait.xpath(element_xpath)
+ session.ice_driver.find_element_by_xpath(element_xpath).click()
+ except Exception as e: # If failed - count the failure and add the error to list of errors.
+ errorMsg = "Failed to click_on on XPATH " + element_xpath
+ raise Exception(errorMsg, e)
+
+ @staticmethod
+ def drag_and_drop_by_css(source_css, xoffset, yoffset):
+ ns = session.ice_driver.find_element_by_id("step-description-1")
+ ActionChains(session.ice_driver).move_to_element(ns).perform()
+ Wait.css(source_css)
+ source_element = session.ice_driver.find_element_by_css_selector(source_css)
+ ActionChains(session.ice_driver).drag_and_drop_by_offset(source_element, xoffset, yoffset).perform()
diff --git a/services/frontend/base_actions/enter.py b/services/frontend/base_actions/enter.py
new file mode 100644
index 0000000..4577a3d
--- /dev/null
+++ b/services/frontend/base_actions/enter.py
@@ -0,0 +1,139 @@
+
+# ============LICENSE_START==========================================
+# org.onap.vvp/test-engine
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the “License”);
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+from datetime import datetime
+import time
+
+from services.frontend.base_actions.wait import Wait
+from services.logging_service import LoggingServiceFactory
+from services.session import session
+
+
+logger = LoggingServiceFactory.get_logger()
+class Enter:
+
+ @staticmethod
+ def text_by_name(attr_name_value, typed_text, wait_for_page=False):
+ try: # Send keys to element in UI, by name locator (e.g. type something in text box).
+ if wait_for_page:
+ Wait.page_has_loaded()
+ Wait.name(attr_name_value)
+ session.ice_driver.find_element_by_name(attr_name_value).clear()
+ session.ice_driver.find_element_by_name(attr_name_value).send_keys(typed_text[:-1])
+ time.sleep(session.wait_until_time_pause)
+ session.ice_driver.find_element_by_name(attr_name_value).send_keys(typed_text[-1:])
+ except Exception as e: # If failed - count the failure and add the error to list of errors.
+ errorMsg = "Failed to type " + typed_text + " in text box"
+ raise Exception(errorMsg, e)
+
+ @staticmethod
+ def text_by_xpath(attr_xpath_value, typed_text, wait_for_page=False):
+ try: # Send keys to element in UI, by name locator (e.g. type something in text box).
+ if wait_for_page:
+ Wait.page_has_loaded()
+ Wait.xpath(attr_xpath_value)
+ session.ice_driver.find_element_by_xpath(attr_xpath_value).clear()
+ session.ice_driver.find_element_by_xpath(attr_xpath_value).send_keys(typed_text[:-1])
+ time.sleep(session.wait_until_time_pause)
+ session.ice_driver.find_element_by_xpath(attr_xpath_value).send_keys(typed_text[-1:])
+ except Exception as e: # If failed - count the failure and add the error to list of errors.
+ errorMsg = "Failed to type " + typed_text + " in text box"
+ raise Exception(errorMsg, attr_xpath_value)
+
+ @staticmethod
+ def text_by_id(attr_id_value, typed_text, wait_for_page=False):
+ try: # Send keys to element in UI, by ID locator (e.g. type something in text box).
+ if wait_for_page:
+ Wait.page_has_loaded()
+ Wait.id(attr_id_value)
+ session.ice_driver.find_element_by_id(attr_id_value).clear()
+ session.ice_driver.find_element_by_id(attr_id_value).send_keys(typed_text[:-1])
+ time.sleep(session.wait_until_time_pause)
+ session.ice_driver.find_element_by_id(attr_id_value).send_keys(typed_text[-1:])
+ except Exception as e: # If failed - count the failure and add the error to list of errors.
+ errorMsg = "Failed to type " + typed_text + " in text box"
+ raise Exception(errorMsg, attr_id_value)
+
+ @staticmethod
+ def clear(attr_id_value):
+ try:
+ Wait.id(attr_id_value)
+ session.ice_driver.find_element_by_id(attr_id_value).clear()
+ except Exception as e:
+ errorMsg = "Failed to clear text box"
+ raise Exception(errorMsg, attr_id_value)
+
+ @staticmethod
+ def text_by_css(attr_css_value, typed_text, wait_for_page=False):
+ try: # Send keys to element in UI, by CSS locator (e.g. type something in text box).
+ if wait_for_page:
+ Wait.page_has_loaded()
+ Wait.css(attr_css_value)
+ session.ice_driver.find_element_by_css_selector(attr_css_value).clear()
+ session.ice_driver.find_element_by_css_selector(attr_css_value).send_keys(typed_text[:-1])
+ time.sleep(session.wait_until_time_pause)
+ session.ice_driver.find_element_by_css_selector(attr_css_value).send_keys(typed_text[-1:])
+ except Exception as e: # If failed - count the failure and add the error to list of errors.
+ errorMsg = "Failed to type " + typed_text + " in text box"
+ raise Exception(errorMsg, attr_css_value)
+
+ @staticmethod
+ def text_by_link_text(attr_link_text_value, typed_text, wait_for_page=False):
+ try: # Send keys to element in UI, by name locator (e.g. type something in text box).
+ if wait_for_page:
+ Wait.page_has_loaded()
+ Wait.link_text(attr_link_text_value)
+ session.ice_driver.find_element_by_link_text(attr_link_text_value).clear()
+ session.ice_driver.find_element_by_link_text(attr_link_text_value).send_keys(typed_text[:-1])
+ time.sleep(session.wait_until_time_pause)
+ session.ice_driver.find_element_by_link_text(attr_link_text_value).send_keys(typed_text[-1:])
+ except Exception as e: # If failed - count the failure and add the error to list of errors.
+ errorMsg = "Failed to type " + typed_text + " in text box"
+ raise Exception(errorMsg, attr_link_text_value)
+
+ @staticmethod
+ def date_picker(selector, property_name, wait_for_page=False):
+ try:
+ if wait_for_page:
+ Wait.page_has_loaded()
+ session.ice_driver.execute_script(
+ "var element = angular.element(document.querySelector('" + selector + "')); element.scope()." +
+ property_name + " = new Date('" + str(datetime.today().isoformat()) + "')")
+ except Exception as e:
+ errorMsg = "Failed to select date with datePicker."
+ raise Exception(errorMsg, str(e))
diff --git a/services/frontend/base_actions/get.py b/services/frontend/base_actions/get.py
new file mode 100644
index 0000000..8735c1b
--- /dev/null
+++ b/services/frontend/base_actions/get.py
@@ -0,0 +1,127 @@
+
+# ============LICENSE_START==========================================
+# org.onap.vvp/test-engine
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the “License”);
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+from services.frontend.base_actions.wait import Wait
+from services.session import session
+
+
+class Get:
+
+ @staticmethod
+ def by_id(attr_id_value, wait_for_page=False):
+ try:
+ if wait_for_page:
+ Wait.page_has_loaded()
+ Wait.id(attr_id_value)
+ return session.ice_driver.find_element_by_id(attr_id_value).text
+ # If failed - count the failure and add the error to list of errors.
+ except Exception as e:
+ errorMsg = "Failed to get text of element " + attr_id_value
+ raise Exception(errorMsg, attr_id_value)
+
+ @staticmethod
+ def by_css(attr_css_value, wait_for_page=False):
+ try:
+ if wait_for_page:
+ Wait.page_has_loaded()
+ Wait.css(attr_css_value)
+ return session.ice_driver.find_element_by_css_selector(attr_css_value).text
+ # If failed - count the failure and add the error to list of errors.
+ except Exception as e:
+ errorMsg = "Failed to get text of element " + attr_css_value
+ raise Exception(errorMsg, attr_css_value)
+
+ @staticmethod
+ def wysiwyg_element_by_id(attr_id_value):
+ try:
+ Wait.id(attr_id_value)
+ return session.ice_driver.find_element_by_css_selector(
+ "#" + attr_id_value + ".wysiwyg-textarea")
+ # If failed - count the failure and add the error to list of errors.
+ except Exception as e:
+ errorMsg = "Failed to get element by id " + attr_id_value
+ raise Exception(errorMsg, attr_id_value)
+
+ @staticmethod
+ def by_name(attr_name_value):
+ try:
+ Wait.name(attr_name_value)
+ return session.ice_driver.find_element_by_name(attr_name_value).text
+ # If failed - count the failure and add the error to list of errors.
+ except Exception as e:
+ errorMsg = "Failed to get text of element " + attr_name_value
+ raise Exception(errorMsg, attr_name_value)
+
+ @staticmethod
+ def by_xpath(attr_name_value):
+ try:
+ Wait.xpath(attr_name_value)
+ return session.ice_driver.find_element_by_xpath(attr_name_value).text
+ # If failed - count the failure and add the error to list of errors.
+ except Exception as e:
+ errorMsg = "Failed to get text of element " + attr_name_value
+ raise Exception(errorMsg, attr_name_value)
+
+ @staticmethod
+ def value_by_name(attr_name_value):
+ try:
+ Wait.name(attr_name_value)
+ return session.ice_driver.find_element_by_name(attr_name_value).get_attribute("value")
+ except Exception as e:
+ errorMsg = "Failed to get value by name:" + attr_name_value
+ raise Exception(errorMsg, attr_name_value)
+
+ @staticmethod
+ def meta_order_by_id(attr_id_value):
+ try:
+ Wait.id(attr_id_value)
+ return session.ice_driver.find_element_by_id(attr_id_value).get_attribute("meta-order")
+ except Exception as e:
+ errorMsg = "Failed to get meta order by id:" + attr_id_value
+ raise Exception(errorMsg, attr_id_value)
+
+ @staticmethod
+ def is_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 session.ice_driver.find_element_by_id(attr_id_value).is_selected()
+ 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
new file mode 100644
index 0000000..50eff08
--- /dev/null
+++ b/services/frontend/base_actions/wait.py
@@ -0,0 +1,317 @@
+
+# ============LICENSE_START==========================================
+# org.onap.vvp/test-engine
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the “License”);
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+import time
+
+from selenium.common.exceptions import NoSuchElementException
+from selenium.webdriver.common.by import By
+from selenium.webdriver.support import expected_conditions
+from selenium.webdriver.support.wait import WebDriverWait
+
+from services.constants import Constants
+from services.logging_service import LoggingServiceFactory
+from services.session import session
+
+
+logger = LoggingServiceFactory.get_logger()
+
+
+class Wait:
+
+ @staticmethod
+ def text_by_xpath(xpath, text, wait_for_page=False):
+ try: # Wait 4 seconds for element and compare to expected result.
+ if wait_for_page:
+ Wait.page_has_loaded()
+ WebDriverWait(session.ice_driver, session.wait_until_retires).until(
+ expected_conditions.text_to_be_present_in_element(
+ (By.XPATH, xpath), text)
+ )
+ # If failed - count the failure and add the error to list of errors.
+ except:
+ error_msg = "Text - " + text + " not found in xPath " + xpath
+ raise Exception(error_msg, xpath)
+
+ @staticmethod
+ def text_by_id(element_id, text, wait_for_page=False):
+ try: # Wait 4 seconds for element and compare to expected result.
+ if wait_for_page:
+ Wait.page_has_loaded()
+ WebDriverWait(session.ice_driver, session.wait_until_retires).until(
+ expected_conditions.text_to_be_present_in_element(
+ (By.ID, element_id), text)
+ )
+ # If failed - count the failure and add the error to list of errors.
+ except:
+ error_msg = "Text - " + text + " not found in ID " + element_id
+ raise Exception(error_msg, element_id)
+
+ @staticmethod
+ def text_by_css(css, text, wait_for_page=False):
+ try: # Wait 4 seconds for element and compare to expected result.
+ if wait_for_page:
+ Wait.page_has_loaded()
+ WebDriverWait(session.ice_driver, session.wait_until_retires).until(
+ expected_conditions.text_to_be_present_in_element(
+ (By.CSS_SELECTOR, css), text)
+ )
+ # If failed - count the failure and add the error to list of errors.
+ except Exception as e:
+ error_msg = "Text - " + text + " not found in CSS - " + css
+ raise Exception(error_msg, e)
+
+ @staticmethod
+ def text_by_name(name, text, wait_for_page=False):
+ try: # Wait 4 seconds for element and compare to expected result.
+ if wait_for_page:
+ Wait.page_has_loaded()
+ WebDriverWait(session.ice_driver, session.wait_until_retires).until(
+ expected_conditions.text_to_be_present_in_element(
+ (By.NAME, name), text)
+ )
+ # If failed - count the failure and add the error to list of errors.
+ except Exception as e:
+ error_msg = "Text - " + text + " not found by NAME - " + name
+ raise Exception(error_msg, e)
+
+ @staticmethod
+ def id(element_id, wait_for_page=False):
+ try: # Wait 4 seconds for element and compare to expected result.
+ if wait_for_page:
+ Wait.page_has_loaded()
+ WebDriverWait(session.ice_driver, session.wait_until_retires).until(
+ expected_conditions.visibility_of_element_located(
+ (By.ID, element_id))
+ )
+ # If failed - count the failure and add the error to list of errors.
+ except Exception as e:
+ error_msg = "Didn't find ID " + element_id
+ raise Exception(error_msg, e)
+
+ @staticmethod
+ def css(element_css, wait_for_page=False):
+ try: # Wait 4 seconds for element and compare to expected result.
+ if wait_for_page:
+ Wait.page_has_loaded()
+ WebDriverWait(session.ice_driver, session.wait_until_retires).until(
+ expected_conditions.visibility_of_element_located(
+ (By.CSS_SELECTOR, element_css))
+ )
+ # If failed - count the failure and add the error to list of errors.
+ except Exception as e:
+ error_msg = "Didn't find CSS Selector " + element_css
+ raise Exception(error_msg, e)
+
+ @staticmethod
+ def is_css_exists(element_css, wait_for_page=False):
+ try: # Wait 4 seconds for element and compare to expected result.
+ if wait_for_page:
+ Wait.page_has_loaded()
+ WebDriverWait(session.ice_driver, session.wait_until_implicit_time).until(
+ expected_conditions.visibility_of_element_located(
+ (By.CSS_SELECTOR, element_css))
+ )
+ return True
+ # If failed - count the failure and add the error to list of errors.
+ except Exception as e:
+ error_msg = "Didn't find CSS Selector " + element_css
+ return False
+
+ @staticmethod
+ def link_text(link_inner_text, wait_for_page=False):
+ try:
+ if wait_for_page:
+ Wait.page_has_loaded()
+ WebDriverWait(session.ice_driver, session.wait_until_retires).until(
+ expected_conditions.visibility_of_element_located(
+ (By.LINK_TEXT, link_inner_text))
+ )
+ # If failed - count the failure and add the error to list of errors.
+ except Exception as e:
+ error_msg = "Didn't find LINK TEXT " + link_inner_text
+ raise Exception(error_msg, e)
+
+ @staticmethod
+ def name(element_name, wait_for_page=False):
+ try:
+ if wait_for_page:
+ Wait.page_has_loaded()
+ WebDriverWait(session.ice_driver, session.wait_until_retires).until(
+ expected_conditions.visibility_of_element_located(
+ (By.NAME, element_name))
+ )
+ # If failed - count the failure and add the error to list of errors.
+ except Exception as e:
+ error_msg = "Didn't find NAME " + element_name
+ raise Exception(error_msg, e)
+
+ @staticmethod
+ def xpath(element_xpath, wait_for_page=False):
+ try:
+ if wait_for_page:
+ Wait.page_has_loaded()
+ WebDriverWait(session.ice_driver, session.wait_until_retires).until(
+ expected_conditions.visibility_of_element_located(
+ (By.XPATH, element_xpath))
+ )
+ # If failed - count the failure and add the error to list of errors.
+ except Exception as e:
+ error_msg = "Didn't find XPath " + element_xpath
+ raise Exception(error_msg, e)
+
+ @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"):
+ 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
+
+ raise Exception("Page loading took too much time")
+
+ @staticmethod
+ def modal_to_dissappear():
+ session.ice_driver.implicitly_wait(0)
+ i = 0
+ not_found = False
+ while i < session.wait_until_retires:
+ try:
+ session.ice_driver.find_element_by_css_selector(
+ Constants.Dashboard.Wizard.Open.CSS)
+ except NoSuchElementException:
+ not_found = True
+ try:
+ session.ice_driver.find_element_by_class_name(
+ Constants.Dashboard.Wizard.Open.CLASS_NAME)
+ not_found = False
+ except NoSuchElementException:
+ not_found = True
+
+ if not_found:
+ break
+
+ else:
+ time.sleep(session.wait_until_time_pause)
+ i += 1
+
+ session.ice_driver.implicitly_wait(session.wait_until_implicit_time)
+ if not_found:
+ return True
+ else:
+ raise Exception("waitForModalToDissapper")
+
+ @staticmethod
+ def id_to_dissappear(id_element, wait_for_page=False):
+ if wait_for_page:
+ Wait.page_has_loaded()
+ session.ice_driver.implicitly_wait(0)
+ i = 0
+ not_found = False
+ while i < session.wait_until_retires:
+ try:
+ session.ice_driver.find_element_by_id(id_element)
+ except NoSuchElementException:
+ not_found = True
+
+ if not_found:
+ break
+ else:
+ time.sleep(session.wait_until_time_pause)
+ i += 1
+
+ session.ice_driver.implicitly_wait(session.wait_until_implicit_time)
+ if not_found:
+ return True
+ else:
+ raise Exception(
+ "id_to_dissappear " + id_element + " num of retries = " + str(i))
+
+ @staticmethod
+ def name_to_dissappear(name_element, wait_for_page=False):
+ if wait_for_page:
+ Wait.page_has_loaded()
+ session.ice_driver.implicitly_wait(0)
+ i = 0
+ not_found = False
+ while i < session.wait_until_retires:
+ try:
+ session.ice_driver.find_element_by_name(name_element)
+ except NoSuchElementException:
+ not_found = True
+
+ if not_found:
+ break
+ else:
+ time.sleep(session.wait_until_time_pause)
+ i += 1
+
+ session.ice_driver.implicitly_wait(session.wait_until_implicit_time)
+ if not_found:
+ return True
+ else:
+ raise Exception(
+ "name_to_dissappear " + name_element + " num of retries = " + str(i))
+
+ @staticmethod
+ def css_to_dissappear(css_element):
+ session.ice_driver.implicitly_wait(0)
+ i = 0
+ not_found = False
+ while i < session.wait_until_retires:
+ try:
+ session.ice_driver.find_element_by_css_selector(css_element)
+ except NoSuchElementException:
+ not_found = True
+
+ if not_found:
+ break
+ else:
+ time.sleep(session.wait_until_time_pause)
+ i += 1
+
+ session.ice_driver.implicitly_wait(session.wait_until_implicit_time)
+ if not_found:
+ return True
+ else:
+ raise Exception("css_to_dissappear" + css_element)