From 68d480dee315ded106158ae1dff8109e44d59f64 Mon Sep 17 00:00:00 2001 From: cesar991 Date: Tue, 26 Jul 2016 11:41:02 +0200 Subject: [PATCH] Repair errors and add edit_service function --- tests/console/include/service_functions.py | 58 +++++++++++++++++++--- 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/tests/console/include/service_functions.py b/tests/console/include/service_functions.py index 9ce4a20e53..a78ad6c77f 100644 --- a/tests/console/include/service_functions.py +++ b/tests/console/include/service_functions.py @@ -5,7 +5,9 @@ from selenium.webdriver.support.ui import WebDriverWait, Select from selenium.webdriver.support import expected_conditions as EC from common_functions_60 import * -import random, time +from time import sleep + +import random, re import string @@ -28,9 +30,14 @@ def create_service(driver,name,group,agent,description=None,mode="Auto",critical driver.find_element_by_id("text-name").send_keys(name) driver.find_element_by_xpath('//option[contains(.,"'+group+'")]').click() - - driver.find_element_by_xpath('//*[@id="text-agent_target"]').clear() - driver.find_element_by_xpath('//*[@id="text-agent_target"]').send_keys(agent) + + driver.find_element_by_xpath('//*[@id="text-agent_target"]').clear() + driver.find_element_by_xpath('//*[@id="text-agent_target"]').send_keys(agent) + + sleep(6) + + driver.find_element_by_xpath('//a[contains(.,"'+agent+'")]').click() + if description != None: @@ -48,13 +55,16 @@ def create_service(driver,name,group,agent,description=None,mode="Auto",critical driver.find_element_by_id("text-warning").clear() driver.find_element_by_id("text-warning").send_keys(warning) + + driver.find_element_by_id("submit-crt").click() - diver.find_elemet_by_id("submit-crt").click() - + def search_service(driver,name,group="All",status="Any",mode="Any",go_to_service=True): # If go_to_service = False this function can not enter in service + click_menu_element(driver,"Services") + driver.find_element_by_xpath('//a[contains(.,"Filter")]').click() driver.find_element_by_id("text-free_search").clear() driver.find_element_by_id("text-free_search").send_keys(name) @@ -80,3 +90,39 @@ def delete_service(driver,name): driver.find_element_by_xpath('//*[@id="table3-0-10"]/a[3]/img').click() alert = driver.switch_to_alert() alert.accept() + + +def edit_service(driver,name,new_name=None,new_group=None,new_description=None,new_mode=None,critical=None,warning=None): + + # If choose new_mode = manual, insert critical and warning variables. + + search_service(driver,name,go_to_service=False) + driver.find_element_by_xpath('//*[@id="table3-0-10"]/a[1]/img').click() + + if new_name != None: + driver.find_element_by_id("text-name").clear() + driver.find_element_by_id("text-name").send_keys(new_name) + + if new_group != None: + driver.find_element_by_xpath('//option[contains(.,"'+new_group+'")]').click() + + if new_description != None: + driver.find_element_by_id("text-description").clear() + driver.find_element_by_id("text-description").send_keys(new_description) + + if new_mode == "simple": + driver.find_element_by_id("radiobtn0003").click() + + if new_mode == "manual": + driver.find_element_by_id("radiobtn0001").click() + + driver.find_element_by_id("text-critical").clear() + driver.find_element_by_id("text-critical").send_keys(critical) + + driver.find_element_by_id("text-warning").clear() + driver.find_element_by_id("text-warning").send_keys(warning) + + if new_mode == "auto": + driver.find_element_by_id("radiobtn0002").click() + + diver.find_elemet_by_id("submit-crt").click()