From dfac3cfc0faa4cef39f7fe228fac1de656eea850 Mon Sep 17 00:00:00 2001 From: axl89 Date: Wed, 15 Jun 2016 11:11:08 +0200 Subject: [PATCH] Added behaviour to pass the wizards --- tests/console/PAN1.py | 3 +- tests/console/PAN2.py | 5 +-- tests/console/PAN3.py | 3 +- tests/console/include/common_functions_60.py | 34 +++++++++++++++++++- 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/tests/console/PAN1.py b/tests/console/PAN1.py index e8a7424926..ed8d31c170 100644 --- a/tests/console/PAN1.py +++ b/tests/console/PAN1.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- from include.common_classes_60 import PandoraWebDriverTestCase -from include.common_functions_60 import login, click_menu_element +from include.common_functions_60 import login, click_menu_element, detect_and_pass_all_wizards from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys @@ -17,6 +17,7 @@ class PAN1(PandoraWebDriverTestCase): def test_pan1(self): driver = self.driver login(driver,"admin","pandora",self.base_url) + detect_and_pass_all_wizards(driver) click_menu_element(driver,"General Setup") self.assertEqual("IP list with API access", driver.find_element_by_id("table2-15-0").text) diff --git a/tests/console/PAN2.py b/tests/console/PAN2.py index f9abb45bb4..70b4d7335b 100644 --- a/tests/console/PAN2.py +++ b/tests/console/PAN2.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- from include.common_classes_60 import PandoraWebDriverTestCase -from include.common_functions_60 import login, click_menu_element +from include.common_functions_60 import login, click_menu_element, detect_and_pass_all_wizards from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys @@ -12,11 +12,12 @@ import unittest, time, re class PAN2(PandoraWebDriverTestCase): test_name = u'PAN_2' test_description = u'Creation two agents and delete this agents using bulk operation' - tickets_associated = [] + tickets_associated = [3831] def test_pan2(self): driver = self.driver login(driver,"admin","pandora",self.base_url) + detect_and_pass_all_wizards(driver) click_menu_element(driver,"Agent detail") driver.find_element_by_id("submit-crt").click() driver.find_element_by_id("text-agente").click() diff --git a/tests/console/PAN3.py b/tests/console/PAN3.py index add7882b9a..a8446be6d7 100644 --- a/tests/console/PAN3.py +++ b/tests/console/PAN3.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- from include.common_classes_60 import PandoraWebDriverTestCase -from include.common_functions_60 import login, click_menu_element, refresh_N_times_until_find_element +from include.common_functions_60 import login, click_menu_element, refresh_N_times_until_find_element, detect_and_pass_all_wizards from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys @@ -18,6 +18,7 @@ class PAN3(PandoraWebDriverTestCase): def test_pan3(self): driver = self.driver login(driver,"admin","pandora",self.base_url) + detect_and_pass_all_wizards(driver) click_menu_element(driver,"Agent detail") driver.find_element_by_id("submit-crt").click() driver.find_element_by_id("text-agente").click() diff --git a/tests/console/include/common_functions_60.py b/tests/console/include/common_functions_60.py index d8789307c5..f58a143e8e 100644 --- a/tests/console/include/common_functions_60.py +++ b/tests/console/include/common_functions_60.py @@ -29,7 +29,7 @@ def get_menu_element(driver,menu_item_text): def click_menu_element(driver,menu_item_text): return driver.execute_script("arguments[0].click();", get_menu_element(driver,menu_item_text)) -def refresh_N_times_until_find_element(driver,n,element_text,how=By.ID,refresh_time=5): +def refresh_N_times_until_find_element(driver,n,element_text,how=By.ID,refresh_time=10): from selenium.common.exceptions import TimeoutException i = 1 @@ -58,3 +58,35 @@ def create_user(driver,userid,userpwd,email=None): driver.find_element_by_name("email").send_keys(email) driver.find_element_by_id("submit-crtbutton").click() + +def is_element_present(driver, how, what): + from selenium.common.exceptions import NoSuchElementException + try: driver.find_element(by=how, value=what) + except NoSuchElementException: return False + return True + +def detect_and_pass_pandorin(driver): + if is_element_present(driver,By.NAME,'clippy_is_annoying'): + driver.find_element_by_id('checkbox-clippy_is_annoying').click() + driver.find_element_by_class_name('introjs-skipbutton').click() + alert = driver.switch_to_alert() + alert.accept() + +def detect_and_pass_initial_wizard(driver): + #We need to distinguish between the REQUIRED wizard + if is_element_present(driver,By.ID,'login_id_dialog'): + driver.find_element_by_id('text-email').clear() + driver.find_element_by_id('text-email').send_keys("test@pandora.com") + driver.find_element_by_id('submit-id_dialog_button').click() + + +def detect_and_pass_newsletter_wizard(driver): + if is_element_present(driver,By.ID,'login_accept_register'): + driver.find_element_by_id('submit-finish_dialog_button').click() + driver.find_element_by_id('submit-yes_registration').click() + + +def detect_and_pass_all_wizards(driver): + detect_and_pass_pandorin(driver) + detect_and_pass_initial_wizard(driver) + detect_and_pass_newsletter_wizard(driver)