Moved develop branch tests to pandora_6.0 branch
This commit is contained in:
parent
35f21def2c
commit
c668f0b582
|
@ -0,0 +1,89 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from include.common_classes_60 import PandoraWebDriverTestCase
|
||||
from include.common_functions_60 import click_menu_element, detect_and_pass_all_wizards, gen_random_string
|
||||
from include.module_functions import create_module
|
||||
from include.agent_functions import create_agent_group
|
||||
from include.policy_functions import *
|
||||
from include.collection_functions import *
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
from selenium.webdriver.support.ui import Select
|
||||
from selenium.common.exceptions import NoSuchElementException
|
||||
from selenium.common.exceptions import NoAlertPresentException
|
||||
from selenium.webdriver.remote.webelement import WebElement
|
||||
import unittest, time, re
|
||||
|
||||
|
||||
class Collections(PandoraWebDriverTestCase):
|
||||
|
||||
test_name = u'Collections'
|
||||
test_description = u'Collection tests'
|
||||
tickets_associated = []
|
||||
|
||||
collection_name = gen_random_string(6)
|
||||
new_collection_name = gen_random_string(6)
|
||||
|
||||
def test_A_create_collection(self):
|
||||
|
||||
driver = self.driver
|
||||
self.login()
|
||||
detect_and_pass_all_wizards(driver)
|
||||
|
||||
create_collection(driver,self.collection_name,"PAN11",group="All",description="Collection with PAN11")
|
||||
|
||||
search_collection(driver,self.collection_name,go_to_collection=False)
|
||||
|
||||
element = driver.find_element_by_xpath('//a[contains(.,self.collection_name)]')
|
||||
self.assertIsInstance(element,WebElement)
|
||||
|
||||
def test_B_edit_collection(self):
|
||||
|
||||
driver = self.driver
|
||||
#login(driver,pandora_url="http://192.168.50.50:84/")
|
||||
#detect_and_pass_all_wizards(driver)
|
||||
|
||||
edit_collection(driver,self.collection_name,new_name=self.new_collection_name,group="Applications",description="Edit collectionPAN11")
|
||||
|
||||
search_collection(driver,self.new_collection_name,go_to_collection=False)
|
||||
|
||||
element = driver.find_element_by_xpath('//a[contains(.,self.new_collection_name)]')
|
||||
self.assertIsInstance(element,WebElement)
|
||||
|
||||
def test_C_create_text_collection(self):
|
||||
|
||||
driver = self.driver
|
||||
#login(driver,pandora_url="http://192.168.50.50:84/")
|
||||
#detect_and_pass_all_wizards(driver)
|
||||
|
||||
create_text_in_collection(driver,self.new_collection_name,"file_collectionPAN11",text_file="test file")
|
||||
|
||||
element = driver.find_element_by_xpath('//a[contains(.,"file_collectionPAN11")]')
|
||||
self.assertIsInstance(element,WebElement)
|
||||
|
||||
def test_D_directory_collection(self):
|
||||
|
||||
driver = self.driver
|
||||
#login(driver,pandora_url="http://192.168.50.50:84/")
|
||||
#detect_and_pass_all_wizards(driver)
|
||||
|
||||
create_directory_in_collection(driver,self.new_collection_name,"directory_collectionPAN11")
|
||||
|
||||
element = driver.find_element_by_xpath('//a[contains(.,"directory_collectionPAN11")]')
|
||||
self.assertIsInstance(element,WebElement)
|
||||
|
||||
|
||||
def test_E_delete_collection(self):
|
||||
|
||||
driver = self.driver
|
||||
#login(driver,pandora_url="http://192.168.50.50:84/")
|
||||
#detect_and_pass_all_wizards(driver)
|
||||
|
||||
delete_collection(driver,self.new_collection_name)
|
||||
|
||||
#Check that New_collectionPAN11 is delete
|
||||
element = driver.find_elements_by_xpath('//a[contains(.,"'+self.new_collection_name+'")]')
|
||||
self.assertEqual(element,[])
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
|
@ -16,7 +16,7 @@ class PAN1(PandoraWebDriverTestCase):
|
|||
|
||||
def test_pan1(self):
|
||||
driver = self.driver
|
||||
login(driver)
|
||||
self.login()
|
||||
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)
|
||||
|
|
|
@ -17,8 +17,7 @@ class PAN2(PandoraWebDriverTestCase):
|
|||
|
||||
def test_pan2(self):
|
||||
driver = self.driver
|
||||
login(driver)
|
||||
detect_and_pass_all_wizards(driver)
|
||||
self.login()
|
||||
|
||||
create_agent(driver,"prueba masivas 1")
|
||||
|
||||
|
|
|
@ -19,8 +19,7 @@ class PAN3(PandoraWebDriverTestCase):
|
|||
|
||||
def test_pan3(self):
|
||||
driver = self.driver
|
||||
login(driver)
|
||||
detect_and_pass_all_wizards(driver)
|
||||
self.login()
|
||||
create_agent(driver,"PAN3_agent",ip="127.0.0.1")
|
||||
|
||||
create_module("network_server",driver,agent_name="PAN3_agent",module_name="PAN3_module",component_group="Network Management",network_component="Host Alive",ip="127.0.0.1")
|
||||
|
|
|
@ -22,8 +22,7 @@ class PAN4(PandoraWebDriverTestCase):
|
|||
|
||||
def test_pan4(self):
|
||||
driver = self.driver
|
||||
login(driver,user="admin",passwd="pandora")
|
||||
detect_and_pass_all_wizards(driver)
|
||||
self.login()
|
||||
|
||||
#Creates a user with Chief Operator - Applications profile
|
||||
profile_list = []
|
||||
|
@ -35,11 +34,10 @@ class PAN4(PandoraWebDriverTestCase):
|
|||
create_report(driver,"PAN_4_Servers","Servers")
|
||||
|
||||
#Logout
|
||||
logout(driver,self.base_url)
|
||||
self.logout()
|
||||
|
||||
#Login
|
||||
login(driver,user='PAN_4',passwd='PAN_4')
|
||||
detect_and_pass_all_wizards(driver)
|
||||
self.login(user='PAN_4',passwd='PAN_4')
|
||||
|
||||
#Check that the report is visible
|
||||
click_menu_element(driver,"Custom reporting")
|
||||
|
@ -69,8 +67,8 @@ class PAN4(PandoraWebDriverTestCase):
|
|||
|
||||
|
||||
#Delete reports
|
||||
logout(driver,self.base_url)
|
||||
login(driver,user="admin",passwd="pandora")
|
||||
self.logout()
|
||||
self.login(user="admin",passwd="pandora")
|
||||
|
||||
delete_report(driver,"PAN_4_Servers")
|
||||
delete_report(driver,"PAN_4_Applications")
|
||||
|
|
|
@ -23,7 +23,7 @@ class PAN5(PandoraWebDriverTestCase):
|
|||
|
||||
def test_pan5(self):
|
||||
driver = self.driver
|
||||
login(driver)
|
||||
self.login()
|
||||
detect_and_pass_all_wizards(driver)
|
||||
|
||||
create_agent(driver,u"次のライセンスに基づいていま")
|
||||
|
|
|
@ -19,13 +19,13 @@ class PAN7(PandoraWebDriverTestCase):
|
|||
def test_pan7(self):
|
||||
|
||||
driver = self.driver
|
||||
login(driver)
|
||||
self.login()
|
||||
detect_and_pass_all_wizards(driver)
|
||||
|
||||
activate_home_screen(driver,"Event list")
|
||||
|
||||
logout(driver,self.base_url)
|
||||
login(driver)
|
||||
self.logout()
|
||||
self.login()
|
||||
|
||||
|
||||
try:
|
||||
|
|
|
@ -21,7 +21,7 @@ class PAN8(PandoraWebDriverTestCase):
|
|||
def test_pan8(self):
|
||||
|
||||
driver = self.driver
|
||||
login(driver)
|
||||
self.login()
|
||||
detect_and_pass_all_wizards(driver)
|
||||
|
||||
create_agent(driver,"PAN_8",group="Applications",ip="192.168.50.50")
|
||||
|
@ -39,9 +39,9 @@ class PAN8(PandoraWebDriverTestCase):
|
|||
|
||||
create_user(driver,"PAN8_user","pandora",profile_list=l)
|
||||
|
||||
logout(driver,self.base_url)
|
||||
self.logout()
|
||||
|
||||
login(driver,user="PAN8_user")
|
||||
self.login(user="PAN8_user")
|
||||
|
||||
detect_and_pass_all_wizards(driver)
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class PAN9(PandoraWebDriverTestCase):
|
|||
def test_pan9(self):
|
||||
|
||||
driver = self.driver
|
||||
login(driver)
|
||||
self.login()
|
||||
detect_and_pass_all_wizards(driver)
|
||||
|
||||
create_agent_group(driver,"PAN9_A",propagate_acl=True,description="Group A, with propagate ACL, son of ALL")
|
||||
|
@ -37,9 +37,9 @@ class PAN9(PandoraWebDriverTestCase):
|
|||
|
||||
create_user(driver,"PAN9_user","pandora",profile_list=l)
|
||||
|
||||
logout(driver,self.base_url)
|
||||
self.logout()
|
||||
|
||||
login(driver,user="PAN9_user")
|
||||
self.login(user="PAN9_user")
|
||||
|
||||
detect_and_pass_all_wizards(driver)
|
||||
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from include.common_classes_60 import PandoraWebDriverTestCase
|
||||
from include.common_functions_60 import login, detect_and_pass_all_wizards, gen_random_string
|
||||
from include.policy_functions import *
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
from selenium.webdriver.support.ui import Select
|
||||
from selenium.common.exceptions import NoSuchElementException
|
||||
from selenium.common.exceptions import NoAlertPresentException
|
||||
from selenium.webdriver.remote.webelement import WebElement
|
||||
import unittest, time, re
|
||||
|
||||
class Policies(PandoraWebDriverTestCase):
|
||||
|
||||
test_name = u'Policies'
|
||||
test_description = u'Policy tests'
|
||||
tickets_associated = []
|
||||
|
||||
policy_name = gen_random_string(6)
|
||||
network_server_module_name = gen_random_string(6)
|
||||
|
||||
def test_1_create_policy(self):
|
||||
|
||||
driver = self.driver
|
||||
self.login()
|
||||
|
||||
create_policy(driver,self.policy_name,"Applications",description="Policy for test")
|
||||
|
||||
search_policy(driver,self.policy_name,go_to_policy=False)
|
||||
|
||||
element = driver.find_element_by_xpath('//a[contains(.,"'+self.policy_name+'")]')
|
||||
self.assertIsInstance(element,WebElement)
|
||||
|
||||
def test_2_add_network_server_module_to_policy(self):
|
||||
|
||||
driver = self.driver
|
||||
|
||||
add_module_policy(driver,self.policy_name,"network_server",driver,module_name=self.network_server_module_name,component_group="Network Management",network_component="Host Alive")
|
||||
|
||||
element = driver.find_element_by_xpath('//td[contains(.,"uccessfully")]')
|
||||
self.assertIsInstance(element,WebElement)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
|
@ -0,0 +1,106 @@
|
|||
# -*- 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_collection(driver,name,short_name,group="All",description=None):
|
||||
|
||||
click_menu_element(driver,"Collections")
|
||||
|
||||
if ("A file collection is a group of files (e.g. scripts or executables)" 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_id("text-short_name").clear()
|
||||
driver.find_element_by_id("text-short_name").send_keys(name)
|
||||
|
||||
if group != "All":
|
||||
driver.find_element_by_xpath('//option[contains(.,"'+group+'")]').click()
|
||||
|
||||
if description != None:
|
||||
driver.find_element_by_id("textarea_description").clear()
|
||||
driver.find_element_by_id("textarea_description").send_keys(description)
|
||||
|
||||
driver.find_element_by_id("submit-submit").click()
|
||||
|
||||
|
||||
def search_collection(driver,name,go_to_collection=True):
|
||||
|
||||
click_menu_element(driver,"Collections")
|
||||
driver.find_element_by_xpath('//*[@id="main"]/form[1]/table/tbody/tr/td[2]/input').clear()
|
||||
driver.find_element_by_xpath('//*[@id="main"]/form[1]/table/tbody/tr/td[2]/input').send_keys(name)
|
||||
driver.find_element_by_xpath('//*[@id="main"]/form[1]/table/tbody/tr/td[3]/input').click()
|
||||
|
||||
if go_to_collection == True:
|
||||
|
||||
driver.find_element_by_xpath('//a[contains(.,"'+name+'")]').click()
|
||||
|
||||
def delete_collection(driver,name):
|
||||
search_collection(driver,name,go_to_collection=False)
|
||||
driver.find_element_by_xpath('//*[@id="agent_list"]/tbody/tr[2]/td[5]/a[1]/img').click()
|
||||
alert = driver.switch_to_alert()
|
||||
alert.accept()
|
||||
|
||||
def edit_collection(driver,name,new_name=None,group=None,description=None):
|
||||
search_collection(driver,name)
|
||||
|
||||
if new_name != None:
|
||||
driver.find_element_by_id("text-name").clear()
|
||||
driver.find_element_by_id("text-name").send_keys(new_name)
|
||||
|
||||
if group != None:
|
||||
driver.find_element_by_xpath('//option[contains(.,"'+group+'")]').click()
|
||||
|
||||
if description != None:
|
||||
driver.find_element_by_id("textarea_description").clear()
|
||||
driver.find_element_by_id("textarea_description").send_keys(description)
|
||||
|
||||
driver.find_element_by_id("submit-submit").click()
|
||||
|
||||
|
||||
def create_text_in_collection(driver,collection_name,file_name,text_file=None):
|
||||
|
||||
#text_file is a content of file.
|
||||
|
||||
search_collection(driver,collection_name)
|
||||
driver.find_element_by_xpath('//*[@id="menu_tab"]/ul/li[2]/a/img').click()
|
||||
driver.find_element_by_xpath('//*[@id="main"]/div[2]/a[2]/img').click()
|
||||
driver.find_element_by_id("text-name_file").clear()
|
||||
driver.find_element_by_id("text-name_file").send_keys(file_name)
|
||||
driver.find_element_by_id("submit-create").click()
|
||||
|
||||
if text_file != None:
|
||||
driver.find_element_by_xpath('//*[@id="main"]/form/table/tbody/tr[2]/td/textarea').clear()
|
||||
driver.find_element_by_xpath('//*[@id="main"]/form/table/tbody/tr[2]/td/textarea').send_keys(text_file)
|
||||
|
||||
driver.find_element_by_xpath('//*[@id="main"]/form/table/tbody/tr[3]/td/input[3]').click()
|
||||
|
||||
|
||||
def create_directory_in_collection(driver,collection_name,directory_name):
|
||||
|
||||
search_collection(driver,collection_name)
|
||||
driver.find_element_by_xpath('//*[@id="menu_tab"]/ul/li[2]/a/img').click()
|
||||
driver.find_element_by_xpath('//*[@id="main"]/div[2]/a[1]/img').click()
|
||||
driver.find_element_by_id('text-dirname').clear()
|
||||
driver.find_element_by_id('text-dirname').send_keys(directory_name)
|
||||
driver.find_element_by_id('submit-crt').click()
|
||||
|
||||
def recreate_collection(driver,collection_name):
|
||||
|
||||
search_collection(driver,collection_name)
|
||||
driver.find_element_by_xpath('//*[@id="button-recreate_file"]').click()
|
||||
alert = driver.switch_to_alert()
|
||||
alert.accept()
|
||||
|
||||
|
|
@ -19,8 +19,6 @@ class ArticaTestResult(TestResult):
|
|||
self.success.append((test,u'Success'))
|
||||
TestResult.addSuccess(self, test)
|
||||
|
||||
|
||||
|
||||
class PandoraWebDriverTestCase(TestCase):
|
||||
test_name = u'' #Name of the test.
|
||||
test_description = u'' #Description of the test
|
||||
|
@ -39,18 +37,27 @@ class PandoraWebDriverTestCase(TestCase):
|
|||
'version': "46",
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.is_development = os.getenv('DEVELOPMENT', False)
|
||||
if cls.is_development != False:
|
||||
cls.driver = webdriver.Firefox()
|
||||
cls.base_url = os.getenv('DEVELOPMENT_URL')
|
||||
else:
|
||||
#Start VM in Sauce Labs
|
||||
cls.driver = webdriver.Remote(command_executor='http://'+cls.sauce_username+':'+cls.sauce_access_key+'@ondemand.saucelabs.com:80/wd/hub',desired_capabilities=cls.desired_cap)
|
||||
cls.sauce_labs_job_id = cls.driver.session_id
|
||||
cls.base_url = "http://127.0.0.1/"
|
||||
|
||||
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
cls.driver.quit()
|
||||
|
||||
def setUp(self):
|
||||
self.time_started = datetime.now()
|
||||
#Start VM in Sauce Labs
|
||||
is_development = os.getenv('DEVELOPMENT', False)
|
||||
if is_development != False:
|
||||
self.driver = webdriver.Firefox()
|
||||
else:
|
||||
self.driver = webdriver.Remote(command_executor='http://'+self.sauce_username+':'+self.sauce_access_key+'@ondemand.saucelabs.com:80/wd/hub',desired_capabilities=self.desired_cap)
|
||||
self.sauce_labs_job_id = self.driver.session_id # We store this information to update the job info when the tests are done
|
||||
|
||||
self.driver.implicitly_wait(30)
|
||||
self.base_url = "http://127.0.0.1/"
|
||||
self.verificationErrors = []
|
||||
self.accept_next_alert = True
|
||||
super(PandoraWebDriverTestCase, self).setUp()
|
||||
|
@ -80,8 +87,39 @@ class PandoraWebDriverTestCase(TestCase):
|
|||
tack = datetime.now()
|
||||
diff = tack - self.time_started
|
||||
self.time_elapsed = diff.seconds
|
||||
self.driver.quit()
|
||||
|
||||
self.assertEqual([], self.verificationErrors)
|
||||
super(PandoraWebDriverTestCase, self).tearDown()
|
||||
|
||||
|
||||
def login(self,user="admin",passwd="pandora",pandora_url=None):
|
||||
print u"Logging in"
|
||||
|
||||
driver = self.driver
|
||||
|
||||
if pandora_url is None:
|
||||
pandora_url = self.base_url
|
||||
|
||||
driver.get(pandora_url+"/pandora_console/index.php")
|
||||
driver.find_element_by_id("nick").clear()
|
||||
driver.find_element_by_id("nick").send_keys(user)
|
||||
driver.find_element_by_id("pass").clear()
|
||||
driver.find_element_by_id("pass").send_keys(passwd)
|
||||
driver.find_element_by_id("submit-login_button").click()
|
||||
|
||||
def logout(self,pandora_url=None):
|
||||
print u"Logging out"
|
||||
|
||||
driver = self.driver
|
||||
|
||||
if pandora_url is None:
|
||||
pandora_url = self.base_url
|
||||
|
||||
if pandora_url[-1] != '/':
|
||||
driver.find_element_by_xpath('//div[@id="container"]//a[@href="'+pandora_url+'/pandora_console/index.php?bye=bye"]').click()
|
||||
else:
|
||||
driver.find_element_by_xpath('//div[@id="container"]//a[@href="'+pandora_url+'pandora_console/index.php?bye=bye"]').click()
|
||||
|
||||
driver.get(pandora_url+"/pandora_console/index.php")
|
||||
refresh_N_times_until_find_element(driver,2,"nick")
|
||||
|
||||
|
|
|
@ -15,8 +15,19 @@ def gen_random_string(size,preffix=None):
|
|||
return random_string
|
||||
|
||||
|
||||
def login(driver,user="admin",passwd="pandora",pandora_url="http://127.0.0.1/"):
|
||||
def login(driver,user="admin",passwd="pandora",pandora_url=None):
|
||||
print u"Logging in"
|
||||
try:
|
||||
print driver.base_url
|
||||
except Exception as e:
|
||||
print "se casco"
|
||||
print e
|
||||
print u"yep"
|
||||
if pandora_url is None:
|
||||
pandora_url = driver.base_url
|
||||
|
||||
print "Pandora url is "+pandora_url
|
||||
|
||||
driver.get(pandora_url+"/pandora_console/index.php")
|
||||
driver.find_element_by_id("nick").clear()
|
||||
driver.find_element_by_id("nick").send_keys(user)
|
||||
|
|
|
@ -0,0 +1,127 @@
|
|||
# -*- 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_planned_downtime(driver,name,group,type_planned,description=None,execution=None,date_from=None,date_to=None,hour_from=None,hour_to=None,periodicity_type=None,from_day=None,to_day=None,list_days=None,list_agent=None):
|
||||
|
||||
|
||||
#type_planned is: Disabled Agents, Quiet or Disabled only Alerts
|
||||
|
||||
#If execution = Once, date_from, date_to, hour_from and hour_to is required. Example time_from: 2016/07/05 hour_from 15:46:48
|
||||
#If exexution = Periodically, hour_from, hour_to is required, periodicity_type is weekly or monthly
|
||||
|
||||
#If periodicity_type is Monthly insert from_day and to_day in argument function
|
||||
#If periodicity_type is Weekly insert list_days, Example list_days=("monday","saturday","sunday")
|
||||
|
||||
#Execution by default is Once, date_from and date_to is date it's today's date
|
||||
|
||||
#list_agent is a list of agent that aplicate this planned downtime
|
||||
|
||||
click_menu_element(driver,"Scheduled downtime")
|
||||
driver.find_element_by_id("submit-create").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()
|
||||
|
||||
if description != None:
|
||||
driver.find_element_by_id("textarea_description").clear()
|
||||
driver.find_element_by_id("textarea_description").send_keys(description)
|
||||
|
||||
driver.find_element_by_xpath('//option[contains(.,"'+type_planned+'")]').click()
|
||||
|
||||
if execution == "Once":
|
||||
driver.find_element_by_id("text-once_date_from").clear()
|
||||
driver.find_element_by_id("text-once_date_from").send_keys(date_from)
|
||||
|
||||
driver.find_element_by_id("text-once_date_to").clear()
|
||||
driver.find_element_by_id("text-once_date_to").send_keys(date_to)
|
||||
|
||||
driver.find_element_by_id("text-once_time_from").clear()
|
||||
driver.find_element_by_id("text-once_time_from").send_keys(hour_from)
|
||||
|
||||
driver.find_element_by_id("text-once_time_to").clear()
|
||||
driver.find_element_by_id("text-once_time_to").send_keys(hour_to)
|
||||
|
||||
if execution == "Periodically":
|
||||
Select(driver.find_element_by_id("type_periodicity")).select_by_visible_text(periodicity_type)
|
||||
|
||||
if periodicity_type == "Monthly":
|
||||
|
||||
Select(driver.find_element_by_id("periodically_day_from")).select_by_visible_text(from_day)
|
||||
Select(driver.find_element_by_id("periodically_day_to")).select_by_visible_text(to_day)
|
||||
|
||||
if periodicity_type == "Weekly":
|
||||
|
||||
for day in list_days:
|
||||
driver.find_element_by_id("checkbox-"+day).click()
|
||||
|
||||
driver.find_element_by_id("text-periodically_time_from").clear()
|
||||
driver.find_element_by_id("text-periodically_time_from").send_keys(hour_from)
|
||||
|
||||
driver.find_element_by_id("text-periodically_time_to").clear()
|
||||
driver.find_element_by_id("text-periodically_time_to").send_keys(hour_to)
|
||||
|
||||
driver.find_element_by_id("submit-crtbutton").click()
|
||||
|
||||
if list_agent != None:
|
||||
for agent in list_agent:
|
||||
Select(driver.find_element_by_id("id_agents")).select_by_visible_text(agent)
|
||||
alert = driver.switch_to_alert()
|
||||
alert.accept()
|
||||
driver.find_element_by_id("submit-add_item").click()
|
||||
|
||||
driver.find_element_by_id("submit-add_item").click()
|
||||
alert = driver.switch_to_alert()
|
||||
alert.accept()
|
||||
|
||||
def search_planned_downtime(driver,name,type_planned=None,date_from=None,date_to=None,show_past_downtimes=False):
|
||||
|
||||
#Example format with date_from and date_to: 2016/07/04
|
||||
#show_past_downtimes=True for select this option
|
||||
#Type can be "Any","Once" or "Periodically", Any is the default
|
||||
|
||||
click_menu_element(driver,"Scheduled downtime")
|
||||
|
||||
driver.find_element_by_id("text-search_text").clear()
|
||||
driver.find_element_by_id("text-search_text").send_keys(name)
|
||||
|
||||
if type_planned != None:
|
||||
driver.find_element_by_xpath('//option[contains(.,"'+type_planned+'")]').click()
|
||||
|
||||
if date_from != None:
|
||||
driver.find_element_by_id("text-date_from").clear()
|
||||
driver.find_element_by_id("text-date_from").send_keys(date_from)
|
||||
|
||||
if date_to != None:
|
||||
driver.find_element_by_id("text-date_to").clear()
|
||||
driver.find_element_by_id("text-date_to").send_keys(date_to)
|
||||
|
||||
if show_past_downtimes == True:
|
||||
driver.find_element_by_id("checkbox-archived").click()
|
||||
|
||||
driver.find_element_by_id("submit-search").click()
|
||||
|
||||
def stop_downtime(driver,name):
|
||||
search_planned_downtime(driver,name)
|
||||
driver.find_element_by_xpath('//*[@id="table3-0-stop"]/a/img').click()
|
||||
|
||||
|
||||
def delete_planned_downtime(driver,name):
|
||||
search_planned_downtime(driver,name)
|
||||
|
||||
if (u"Running" in driver.page_source):
|
||||
stop_downtime(driver,name)
|
||||
|
||||
search_planned_downtime(driver,name,show_past_downtimes=True)
|
||||
driver.find_element_by_xpath('//*[@id="delete_downtime"]/img').click()
|
||||
alert = driver.switch_to_alert()
|
||||
alert.accept()
|
|
@ -22,3 +22,53 @@ def create_policy(driver,policy_name,group,description=None):
|
|||
driver.find_element_by_id("textarea_description").send_keys(description)
|
||||
|
||||
driver.find_element_by_id("submit-crt").click()
|
||||
|
||||
|
||||
def search_policy(driver,policy_name,go_to_policy=True):
|
||||
click_menu_element(driver,"Manage policies")
|
||||
driver.find_element_by_id("text-text_search").clear()
|
||||
driver.find_element_by_id("text-text_search").send_keys(policy_name)
|
||||
driver.find_element_by_id("submit-submit").click()
|
||||
# If go_to_policy is True, this function enter in options of this policy
|
||||
|
||||
if go_to_policy == True:
|
||||
driver.find_element_by_xpath('//*[@id="policies_list-0-1"]/span/strong/a/span').click()
|
||||
|
||||
|
||||
def add_module_policy(driver,policy_name,module_type,*args,**kwargs):
|
||||
search_policy(driver,policy_name,go_to_policy=True)
|
||||
driver.find_element_by_xpath('//*[@id="menu_tab"]/ul/li[2]/a/img').click()
|
||||
create_module(module_type,*args,**kwargs)
|
||||
|
||||
|
||||
def add_collection_to_policy(driver,policy_name,collection_name):
|
||||
|
||||
search_policy(driver,policy_name,go_to_policy=True)
|
||||
driver.find_element_by_xpath('//*[@id="menu_tab"]/ul/li[6]/a/img').click()
|
||||
|
||||
driver.find_element_by_xpath('//*[@id="main"]/table[2]/tbody/tr/td[2]/form/input[2]').clear()
|
||||
driver.find_element_by_xpath('//*[@id="main"]/table[2]/tbody/tr/td[2]/form/input[2]').send_keys(collection_name)
|
||||
driver.find_element_by_xpath('//*[@id="main"]/table[2]/tbody/tr/td[3]/input').click()
|
||||
|
||||
driver.find_element_by_xpath('//*[@id="table3-0-4"]/a/img').click()
|
||||
|
||||
|
||||
def apply_policy_to_agent(driver,policy_name,list_agent):
|
||||
|
||||
#Example by list_agent: list_agent=("PAN_14_1","PAN_14_2")
|
||||
|
||||
search_policy(driver,policy_name,go_to_policy=True)
|
||||
driver.find_element_by_xpath('//*[@id="menu_tab"]/ul/li[10]/a/img').click()
|
||||
|
||||
for agent in list_agent:
|
||||
Select(driver.find_element_by_id("id_agents")).select_by_visible_text(agent)
|
||||
|
||||
driver.find_element_by_xpath('//*[@id="image-add1"]').click()
|
||||
alert = driver.switch_to_alert()
|
||||
alert.accept()
|
||||
|
||||
driver.find_element_by_xpath('//*[@id="menu_tab"]/ul/li[9]/a/img').click()
|
||||
|
||||
driver.find_element_by_xpath('//*[@id="main"]/div[4]/form[2]').click()
|
||||
alert = driver.switch_to_alert()
|
||||
alert.accept()
|
||||
|
|
|
@ -33,3 +33,6 @@ def delete_report(driver,report_name):
|
|||
driver.find_element_by_id('image-delete2').click()
|
||||
alert = driver.switch_to_alert()
|
||||
alert.accept()
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,128 @@
|
|||
# -*- 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 *
|
||||
|
||||
from time import sleep
|
||||
|
||||
import random, re
|
||||
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)
|
||||
|
||||
sleep(6)
|
||||
|
||||
driver.find_element_by_xpath('//a[contains(.,"'+agent+'")]').click()
|
||||
|
||||
|
||||
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)
|
||||
|
||||
driver.find_element_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)
|
||||
|
||||
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()
|
||||
|
||||
|
||||
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()
|
|
@ -187,4 +187,9 @@ def create_user_profile(driver,profile_name,bit_list=[]):
|
|||
driver.find_element_by_xpath('//*[@id="checkbox-pandora_management"]').click()
|
||||
|
||||
driver.find_element_by_id("submit-crt").click()
|
||||
|
||||
|
||||
def delete_user(driver,user_name):
|
||||
search_user(driver,user_name)
|
||||
driver.find_element_by_xpath('//*[@id="table3-0-6"]/a[3]/img').click()
|
||||
alert = driver.switch_to_alert()
|
||||
alert.accept()
|
||||
|
|
Loading…
Reference in New Issue