Added create, search and delete service funtions and add service_functions.py
This commit is contained in:
parent
dda6e98dc6
commit
f26a89aa12
|
@ -0,0 +1,82 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from selenium import selenium
|
||||
from selenium.webdriver.common.by import By
|
||||
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
|
||||
import string
|
||||
|
||||
|
||||
def create_service(driver,name,group,agent,description=None,mode="Auto",critical=None,warning=None):
|
||||
|
||||
# Mode by defect is "Auto". Mode can be "Auto", "Simple" or "Manual".
|
||||
# If mode = "manual" insert critial and warning values
|
||||
|
||||
click_menu_element(driver,"Services")
|
||||
|
||||
# We check if we have any service or not because the menu change
|
||||
|
||||
if ("A service is a way to group your IT resources based on their functionalities." in driver.page_source) == True:
|
||||
driver.find_element_by_xpath('//*[@id="main"]/div[2]/div[2]/form/input').click()
|
||||
|
||||
else:
|
||||
driver.find_element_by_id("submit-crt").click()
|
||||
|
||||
driver.find_element_by_id("text-name").clear()
|
||||
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)
|
||||
|
||||
if description != None:
|
||||
|
||||
driver.find_element_by_id("text-description").clear()
|
||||
driver.find_element_by_id("text-description").send_keys(description)
|
||||
|
||||
if mode == "simple":
|
||||
driver.find_element_by_id("radiobtn0003").click()
|
||||
|
||||
if 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)
|
||||
|
||||
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
|
||||
|
||||
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)
|
||||
|
||||
if group != None:
|
||||
driver.find_element_by_xpath('//option[contains(.,"'+group+'")]').click()
|
||||
|
||||
if status != "Any":
|
||||
driver.find_element_by_xpath('//option[contains(.,"'+status+'")]').click()
|
||||
|
||||
if mode != "Any":
|
||||
driver.find_element_by_xpath('//option[contains(.,"'+mode+'")]').click()
|
||||
|
||||
driver.find_element_by_id("submit-search").click()
|
||||
|
||||
if go_to_service == True:
|
||||
driver.find_element_by_xpath('//a[contains(.,"'+name+'")]').click()
|
||||
|
||||
|
||||
def delete_service(driver,name):
|
||||
|
||||
search_service(driver,name,go_to_service=False)
|
||||
driver.find_element_by_xpath('//*[@id="table3-0-10"]/a[3]/img').click()
|
||||
alert = driver.switch_to_alert()
|
||||
alert.accept()
|
Loading…
Reference in New Issue