Brought tests from develop to 6.0 branch
This commit is contained in:
parent
80a9739f4c
commit
8385e5e129
|
@ -16,7 +16,7 @@ class PAN1(PandoraWebDriverTestCase):
|
|||
|
||||
def test_pan1(self):
|
||||
driver = self.driver
|
||||
login(driver,"admin","pandora",self.base_url)
|
||||
login(driver)
|
||||
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)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from include.common_classes_60 import PandoraWebDriverTestCase
|
||||
from include.common_functions_60 import login, click_menu_element, detect_and_pass_all_wizards
|
||||
from include.agent_functions import create_agent
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
|
@ -13,24 +14,18 @@ class PAN2(PandoraWebDriverTestCase):
|
|||
test_name = u'PAN_2'
|
||||
test_description = u'Creation two agents and delete this agents using bulk operation'
|
||||
tickets_associated = [3831]
|
||||
|
||||
|
||||
def test_pan2(self):
|
||||
driver = self.driver
|
||||
login(driver,"admin","pandora",self.base_url)
|
||||
login(driver)
|
||||
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()
|
||||
driver.find_element_by_id("text-agente").clear()
|
||||
driver.find_element_by_id("text-agente").send_keys("prueba masivas 1")
|
||||
driver.find_element_by_id("submit-crtbutton").click()
|
||||
|
||||
create_agent(driver,"prueba masivas 1")
|
||||
|
||||
driver.find_element_by_css_selector("b").click()
|
||||
click_menu_element(driver,"Agent detail")
|
||||
driver.find_element_by_id("submit-crt").click()
|
||||
driver.find_element_by_id("text-agente").click()
|
||||
driver.find_element_by_id("text-agente").clear()
|
||||
driver.find_element_by_id("text-agente").send_keys("prueba masivas 2")
|
||||
driver.find_element_by_id("submit-crtbutton").click()
|
||||
|
||||
create_agent(driver,"prueba masivas 2")
|
||||
|
||||
driver.find_element_by_css_selector("b").click()
|
||||
driver.find_element_by_css_selector("b").click()
|
||||
click_menu_element(driver,"Agents operations")
|
||||
|
@ -44,7 +39,6 @@ class PAN2(PandoraWebDriverTestCase):
|
|||
self.assertEqual(self.driver.find_element_by_xpath('//div[@id="main"]//td[contains(.,"Successfully deleted (2)")]').text,"Successfully deleted (2)")
|
||||
except AssertionError as e:
|
||||
self.verificationErrors.append(str(e))
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# -*- 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, detect_and_pass_all_wizards
|
||||
from include.agent_functions import create_agent
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
|
@ -17,17 +18,9 @@ class PAN3(PandoraWebDriverTestCase):
|
|||
|
||||
def test_pan3(self):
|
||||
driver = self.driver
|
||||
login(driver,"admin","pandora",self.base_url)
|
||||
login(driver)
|
||||
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()
|
||||
driver.find_element_by_id("text-agente").clear()
|
||||
driver.find_element_by_id("text-agente").send_keys("localhost icmp test")
|
||||
driver.find_element_by_id("text-direccion").click()
|
||||
driver.find_element_by_id("text-direccion").clear()
|
||||
driver.find_element_by_id("text-direccion").send_keys("127.0.0.1")
|
||||
driver.find_element_by_id("submit-crtbutton").click()
|
||||
create_agent(driver,"localhost icmp test",ip="127.0.0.1")
|
||||
driver.find_element_by_css_selector("li.nomn.tab_godmode > a > img.forced_title").click()
|
||||
driver.find_element_by_id("moduletype").click()
|
||||
Select(driver.find_element_by_id("moduletype")).select_by_visible_text("Create a new network server module")
|
||||
|
|
|
@ -2,8 +2,10 @@
|
|||
|
||||
# -*- 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, detect_and_pass_all_wizards, create_user, is_element_present, create_report, logout, delete_report
|
||||
from include.common_functions_60 import login, click_menu_element, refresh_N_times_until_find_element, detect_and_pass_all_wizards, is_element_present, logout
|
||||
from selenium import webdriver
|
||||
from include.reports_functions import delete_report, create_report
|
||||
from include.user_functions import create_user
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
from selenium.webdriver.support.ui import Select
|
||||
|
@ -24,7 +26,7 @@ class PAN4(PandoraWebDriverTestCase):
|
|||
|
||||
#Creates a user with Chief Operator - Applications profile
|
||||
profile_list = []
|
||||
profile_list.append(("Chief Operator","Applications"))
|
||||
profile_list.append(("Chief Operator","Applications",[]))
|
||||
create_user(driver,'PAN_4','PAN_4',email='pan_4@pandorafms.com',profile_list=profile_list)
|
||||
|
||||
#Creates report
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
|
||||
# -*- 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, detect_and_pass_all_wizards, is_element_present, logout
|
||||
from include.reports_functions import create_report, delete_report
|
||||
from include.user_functions import create_user
|
||||
from include.agent_functions import create_agent
|
||||
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 StaleElementReferenceException, NoSuchElementException
|
||||
import unittest, time, re
|
||||
|
||||
class PAN5(PandoraWebDriverTestCase):
|
||||
|
||||
test_name = u'PAN_5'
|
||||
test_description = u'Creates an agent and a module with japanese characters and test if the event list show the characters properly'
|
||||
tickets_associated = []
|
||||
|
||||
def test_pan5(self):
|
||||
driver = self.driver
|
||||
login(driver)
|
||||
detect_and_pass_all_wizards(driver)
|
||||
|
||||
create_agent(driver,u"次のライセンスに基づいていま")
|
||||
|
||||
#Create module
|
||||
driver.find_element_by_xpath('//ul[@class="mn"]/li/a/img[@data-title="Modules"]').click()
|
||||
Select(driver.find_element_by_id("moduletype")).select_by_visible_text("Create a new network server module")
|
||||
driver.find_element_by_name("updbutton").click()
|
||||
Select(driver.find_element_by_id("network_component_group")).select_by_visible_text("Network Management")
|
||||
Select(driver.find_element_by_id("network_component")).select_by_visible_text("Host Alive")
|
||||
time.sleep(3)
|
||||
driver.find_element_by_id("text-name").clear()
|
||||
driver.find_element_by_id("text-name").send_keys(u"管理者ガイド")
|
||||
driver.find_element_by_id("submit-crtbutton").click()
|
||||
|
||||
#Create alert
|
||||
driver.find_element_by_xpath('//ul[@class="mn"]/li/a/img[@data-title="Alerts"]').click()
|
||||
Select(driver.find_element_by_id("id_agent_module")).select_by_visible_text(u"管理者ガイド")
|
||||
Select(driver.find_element_by_id("template")).select_by_visible_text("Critical condition")
|
||||
Select(driver.find_element_by_id("action_select")).select_by_visible_text("Default action")
|
||||
driver.find_element_by_id("submit-add").click()
|
||||
|
||||
#Force alert
|
||||
click_menu_element(driver,"Agent detail")
|
||||
driver.find_element_by_id("text-search").clear()
|
||||
driver.find_element_by_id("text-search").send_keys(u"次のライセンスに基づいていま")
|
||||
driver.find_element_by_id("submit-srcbutton").click()
|
||||
driver.find_element_by_css_selector("b").click()
|
||||
driver.find_element_by_xpath('//ul[@class="mn"]/li/a/img[@data-title="Alerts"]').click()
|
||||
driver.find_element_by_xpath('//tr[@id="table2-0"]/td/a/img[@data-title="Force"]').click()
|
||||
time.sleep(10)
|
||||
|
||||
#Search events of our agent
|
||||
click_menu_element(driver,"View events")
|
||||
driver.find_element_by_xpath('//a[contains(.,"Event control filter")]').click()
|
||||
driver.find_element_by_xpath('//a[contains(.,"Advanced options")]').click()
|
||||
driver.find_element_by_id("text-text_agent").clear()
|
||||
driver.find_element_by_id("text-text_agent").send_keys(u"次のライセンスに基づいていま")
|
||||
driver.find_element_by_id("text-module_search").clear()
|
||||
driver.find_element_by_id("text-module_search").send_keys(u"管理者ガイド")
|
||||
driver.find_element_by_id("submit-update").click()
|
||||
|
||||
#Check that there are japanese characters present on the event
|
||||
try:
|
||||
self.assertEqual(True,u"Alert fired (Critical condition) assigned to (管理者ガイド)" in driver.page_source)
|
||||
except AssertionError as e:
|
||||
self.verificationErrors.append(str(e))
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from include.common_classes_60 import PandoraWebDriverTestCase
|
||||
from include.common_functions_60 import login, logout, click_menu_element, detect_and_pass_all_wizards, activate_home_screen
|
||||
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
|
||||
import unittest, time, re
|
||||
|
||||
class PAN7(PandoraWebDriverTestCase):
|
||||
|
||||
test_name = u'PAN_7'
|
||||
test_description = u'Modify home screen, and check that change is correct. Return this change'
|
||||
tickets_associated = []
|
||||
|
||||
def test_pan7(self):
|
||||
|
||||
driver = self.driver
|
||||
login(driver)
|
||||
detect_and_pass_all_wizards(driver)
|
||||
|
||||
activate_home_screen(driver,"Event list")
|
||||
|
||||
logout(driver,self.base_url)
|
||||
login(driver)
|
||||
|
||||
try:
|
||||
|
||||
self.assertEqual("Event control filter" in driver.page_source,True)
|
||||
|
||||
except AssertionError as e:
|
||||
|
||||
self.verificationErrors.append(str(e))
|
||||
|
||||
#Return this change
|
||||
|
||||
activate_home_screen(driver,"Default")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from include.common_classes_60 import PandoraWebDriverTestCase
|
||||
from include.common_functions_60 import login, click_menu_element, detect_and_pass_all_wizards, logout
|
||||
from include.agent_functions import create_agent, search_agent
|
||||
from include.user_functions import create_user
|
||||
from include.module_functions import create_network_server_module
|
||||
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
|
||||
import unittest, time, re
|
||||
|
||||
class PAN8(PandoraWebDriverTestCase):
|
||||
|
||||
test_name = u'PAN_8'
|
||||
test_description = u'Create agent and two modules, one without tag and with tag, create a user with tag and check this user can view module with tag and user can´t view module without tag'
|
||||
tickets_associated = []
|
||||
|
||||
def test_pan8(self):
|
||||
|
||||
driver = self.driver
|
||||
login(driver)
|
||||
detect_and_pass_all_wizards(driver)
|
||||
|
||||
create_agent(driver,"PAN_8",group="Applications",ip="192.168.50.50")
|
||||
|
||||
#We create a module without a tag
|
||||
|
||||
create_network_server_module(driver,"PAN_8",module_name="Without tag",component_group="Network Management",network_component="Host Alive",ip="192.168.50.50")
|
||||
|
||||
#We now create a modulo with tag "critical"
|
||||
|
||||
create_network_server_module(driver,"PAN_8",module_name="With tag",component_group="Network Management",network_component="Host Alive",ip="192.168.50.50",tag_name="critical")
|
||||
|
||||
l = [("Operator (Read)","All",["critical"])]
|
||||
|
||||
create_user(driver,"PAN8_user","pandora",profile_list=l)
|
||||
|
||||
logout(driver,self.base_url)
|
||||
|
||||
login(driver,user="PAN8_user")
|
||||
|
||||
detect_and_pass_all_wizards(driver)
|
||||
|
||||
search_agent(driver,"PAN_8")
|
||||
|
||||
try:
|
||||
#The user should be able to see the module with Tag
|
||||
self.assertEqual("With tag" in driver.page_source,True)
|
||||
except AssertionError as e:
|
||||
self.verificationErrors.append(str(e))
|
||||
|
||||
try:
|
||||
#The user should NOT be able to see the module without tag
|
||||
self.assertEqual("Without tag" in driver.page_source,False)
|
||||
except AssertionError as e:
|
||||
self.verificationErrors.append(str(e))
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
|
@ -0,0 +1,52 @@
|
|||
# -*- 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 delete_agent (driver,agent_names_list):
|
||||
|
||||
click_menu_element(driver,"Agents operations")
|
||||
driver.find_element_by_id("option").click()
|
||||
Select(driver.find_element_by_id("option")).select_by_visible_text("Bulk agent delete")
|
||||
|
||||
for agent_name in agent_names_list:
|
||||
Select(driver.find_element_by_id("id_agents")).select_by_visible_text(agent_name)
|
||||
|
||||
driver.find_element_by_id("submit-go").click()
|
||||
|
||||
def search_agent(driver,agent_name):
|
||||
|
||||
click_menu_element(driver,"Agent detail")
|
||||
driver.find_element_by_id("text-search").click()
|
||||
driver.find_element_by_id("text-search").clear()
|
||||
driver.find_element_by_id("text-search").send_keys(agent_name)
|
||||
driver.find_element_by_id("submit-srcbutton").click()
|
||||
driver.find_element_by_css_selector("b").click()
|
||||
|
||||
def create_agent(driver,agent_name,ip=None,description=None,group=None,os_id=None):
|
||||
|
||||
click_menu_element(driver,"Agent detail")
|
||||
driver.find_element_by_id("submit-crt").click()
|
||||
driver.find_element_by_id("text-agente").send_keys(agent_name)
|
||||
|
||||
if ip != None:
|
||||
driver.find_element_by_id("text-direccion").clear()
|
||||
driver.find_element_by_id("text-direccion").send_keys(ip)
|
||||
|
||||
if description != None:
|
||||
driver.find_element_by_id("text-comentarios").clear()
|
||||
driver.find_element_by_id("text-comentarios").send_keys(description)
|
||||
|
||||
if group != None:
|
||||
Select(driver.find_element_by_id("grupo")).select_by_visible_text(group)
|
||||
|
||||
if os_id !=None:
|
||||
Select(driver.find_element_by_id("id_os")).select_by_visible_text(os_id)
|
||||
|
||||
driver.find_element_by_id("submit-crtbutton").click()
|
||||
|
|
@ -4,7 +4,7 @@ from selenium.webdriver.common.by import By
|
|||
from selenium.webdriver.support.ui import WebDriverWait, Select
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
|
||||
import random
|
||||
import random, time
|
||||
import string
|
||||
|
||||
def gen_random_string(size,preffix=None):
|
||||
|
@ -52,89 +52,8 @@ def logout(driver,url):
|
|||
driver.get(url+"/pandora_console/index.php")
|
||||
refresh_N_times_until_find_element(driver,2,"nick")
|
||||
|
||||
def create_report(driver,nombre,group_name):
|
||||
click_menu_element(driver,"Custom reporting")
|
||||
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(nombre)
|
||||
if group_name == "All":
|
||||
Select(driver.find_element_by_id("id_group")).select_by_visible_text(group_name)
|
||||
else:
|
||||
#TODO This will not work when choosing a group within a group within another group
|
||||
Select(driver.find_element_by_id("id_group")).select_by_visible_text(" "+group_name)
|
||||
driver.find_element_by_id("submit-add").click()
|
||||
|
||||
|
||||
def delete_report(driver,report_name):
|
||||
click_menu_element(driver,"Custom reporting")
|
||||
driver.find_element_by_id('text-search').clear()
|
||||
driver.find_element_by_id('text-search').send_keys(report_name)
|
||||
driver.find_element_by_id('submit-search_submit').click()
|
||||
driver.find_element_by_id('image-delete2').click()
|
||||
alert = driver.switch_to_alert()
|
||||
alert.accept()
|
||||
|
||||
|
||||
def add_user_profile(driver,user_name,profile,group):
|
||||
click_menu_element(driver,"Users management")
|
||||
driver.find_element_by_css_selector("b").click()
|
||||
driver.find_element_by_id("text-filter_search").clear()
|
||||
driver.find_element_by_id("text-filter_search").send_keys(user_name)
|
||||
driver.find_element_by_id("submit-search").click()
|
||||
driver.find_element_by_xpath('//*[@id="table3-0-6"]/a[2]').click()
|
||||
Select(driver.find_element_by_id("assign_profile")).select_by_visible_text(profile)
|
||||
|
||||
if group == "All":
|
||||
Select(driver.find_element_by_id("assign_group")).select_by_visible_text(group)
|
||||
else:
|
||||
#TODO This will not work when choosing a group within a group within another group
|
||||
Select(driver.find_element_by_id("assign_group")).select_by_visible_text(" "+group)
|
||||
|
||||
#driver.find_element_by_id("image-add2").click()
|
||||
driver.find_element_by_xpath('//*[@name="add"]').click()
|
||||
|
||||
|
||||
def create_user(driver,user_name,userpwd,email=None,profile_list=None):
|
||||
u"""
|
||||
Profile list es una LISTA de TUPLAS:
|
||||
l = [("Chief Operator","All"),("Read Operator","Servers")]
|
||||
"""
|
||||
click_menu_element(driver,"Users management")
|
||||
driver.find_element_by_id("submit-crt").click()
|
||||
driver.find_element_by_name("id_user").clear()
|
||||
driver.find_element_by_name("id_user").send_keys(user_name)
|
||||
driver.find_element_by_name("password_new").clear()
|
||||
driver.find_element_by_name("password_new").send_keys(userpwd)
|
||||
driver.find_element_by_name("password_confirm").clear()
|
||||
driver.find_element_by_name("password_confirm").send_keys(userpwd)
|
||||
driver.find_element_by_name("email").clear()
|
||||
if email != None:
|
||||
driver.find_element_by_name("email").clear()
|
||||
driver.find_element_by_name("email").send_keys(email)
|
||||
driver.find_element_by_id("submit-crtbutton").click()
|
||||
|
||||
if profile_list != None:
|
||||
for profile_name,group_name in profile_list:
|
||||
add_user_profile(driver,user_name,profile_name,group_name)
|
||||
|
||||
def search_user(driver,user_name):
|
||||
click_menu_element(driver,"Users management")
|
||||
driver.find_element_by_css_selector("b").click()
|
||||
driver.find_element_by_id('text-filter_search').clear()
|
||||
driver.find_element_by_id("text-filter_search").send_keys(user_name)
|
||||
driver.find_element_by_id("submit-search").click()
|
||||
|
||||
def is_element_present(driver, how, what):
|
||||
from selenium.common.exceptions import NoSuchElementException
|
||||
try:
|
||||
driver.implicitly_wait(5)
|
||||
driver.find_element(by=how, value=what)
|
||||
except NoSuchElementException:
|
||||
driver.implicitly_wait(5)
|
||||
return False
|
||||
|
||||
driver.implicitly_wait(30)
|
||||
return True
|
||||
#Pass Wizards
|
||||
|
||||
def detect_and_pass_pandorin(driver):
|
||||
if is_element_present(driver,By.NAME,'clippy_is_annoying'):
|
||||
|
@ -162,16 +81,21 @@ def detect_and_pass_all_wizards(driver):
|
|||
detect_and_pass_initial_wizard(driver)
|
||||
detect_and_pass_newsletter_wizard(driver)
|
||||
|
||||
|
||||
def delete_agent (driver,agent_names_list):
|
||||
def activate_home_screen(driver,mode):
|
||||
|
||||
click_menu_element(driver,"Agents operations")
|
||||
driver.find_element_by_id("option").click()
|
||||
Select(driver.find_element_by_id("option")).select_by_visible_text("Bulk agent delete")
|
||||
|
||||
for agent_name in agent_names_list:
|
||||
Select(driver.find_element_by_id("id_agents")).select_by_visible_text(agent_name)
|
||||
|
||||
driver.find_element_by_id("submit-go").click()
|
||||
click_menu_element(driver,"Edit my user")
|
||||
Select(driver.find_element_by_id("section")).select_by_visible_text(mode)
|
||||
driver.find_element_by_id("submit-uptbutton").click()
|
||||
|
||||
def is_element_present(driver, how, what):
|
||||
from selenium.common.exceptions import NoSuchElementException
|
||||
try:
|
||||
driver.implicitly_wait(5)
|
||||
driver.find_element(by=how, value=what)
|
||||
except NoSuchElementException:
|
||||
driver.implicitly_wait(5)
|
||||
return False
|
||||
|
||||
driver.implicitly_wait(30)
|
||||
return True
|
||||
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
# -*- 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_new_dashboard(driver,name,group):
|
||||
|
||||
click_menu_element(driver,"Main dashboard")
|
||||
driver.find_element_by_xpath('//*[@id="menu_tab"]/ul/li[4]/a/img').click()
|
||||
driver.find_element_by_xpath('//*[@id="table2-0-1"]/a[2]/img').click()
|
||||
driver.find_element_by_id("text-name").send_keys(name)
|
||||
Select(driver.find_element_by_id("group")).select_by_visible_text(group)
|
||||
driver.find_element_by_id('submit-add-btn').click()
|
||||
|
||||
def delete_dashboard(driver,name):
|
||||
|
||||
click_menu_element(driver,"Main dashboard")
|
||||
driver.find_element_by_xpath('//*[@id="menu_tab"]/ul/li[4]/a/img').click()
|
||||
Select(driver.find_element_by_id("id_dashboard")).select_by_visible_text(name)
|
||||
driver.find_element_by_xpath('//*[@id="menu_tab"]/ul/li[4]/a/img').click()
|
||||
driver.find_element_by_xpath('//*[@id="table2-0-1"]/a[1]/img').click()
|
||||
|
||||
|
||||
def edit_dashboard(driver,name,new_number_cell=None,new_group=None,new_name=None):
|
||||
|
||||
click_menu_element(driver,"Main dashboard")
|
||||
driver.find_element_by_xpath('//*[@id="menu_tab"]/ul/li[4]/a/img').click()
|
||||
Select(driver.find_element_by_id("id_dashboard")).select_by_visible_text(name)
|
||||
|
||||
if new_number_cell != None:
|
||||
driver.find_element_by_xpath('//*[@id="menu_tab"]/ul/li[4]/a/img').click()
|
||||
driver.find_element_by_id("text-number_cells").clear()
|
||||
driver.find_element_by_id("text-number_cells").send_keys(new_number_cell)
|
||||
driver.find_element_by_id('button-update_cells').click()
|
||||
time.sleep(3)
|
||||
|
||||
if new_group != None:
|
||||
driver.find_element_by_xpath('//*[@id="menu_tab"]/ul/li[4]/a/img').click()
|
||||
Select(driver.find_element_by_id("group_dashboard")).select_by_visible_text(new_group)
|
||||
driver.find_element_by_id('button-update_group_dashboard').click()
|
||||
time.sleep(3)
|
||||
|
||||
if new_name != None:
|
||||
driver.find_element_by_xpath('//*[@id="menu_tab"]/ul/li[4]/a/img').click()
|
||||
driver.find_element_by_id("text-name_dashboard").clear()
|
||||
driver.find_element_by_id("text-name_dashboard").send_keys(new_name)
|
||||
driver.find_element_by_id('button-update_name_dashboard').click()
|
||||
|
|
@ -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 agent_functions import search_agent
|
||||
from common_functions_60 import *
|
||||
|
||||
import random, time
|
||||
import string
|
||||
|
||||
|
||||
def create_network_server_module(driver,agent_name,module_name=None,component_group=None,type=None,network_component=None,min_warning=None,max_warning=None,min_critical=None,max_critical=None,ip=None,tag_name=None,description=None):
|
||||
|
||||
# component_group -> Example: Remote ICMP network agent (latency)
|
||||
# network_component -> Example: Host Alive
|
||||
|
||||
#The type variable is optional, but required if component_group and network_component variables are specified
|
||||
|
||||
search_agent(driver,agent_name)
|
||||
|
||||
driver.find_element_by_xpath('//ul[@class="mn"]/li/a/img[@data-title="Manage"]').click()
|
||||
driver.find_element_by_xpath('//ul[@class="mn"]/li/a/img[@data-title="Modules"]').click()
|
||||
Select(driver.find_element_by_id("moduletype")).select_by_visible_text("Create a new network server module")
|
||||
driver.find_element_by_xpath('//*[@id="create_module_type"]/table/tbody/tr/td[5]/input').click()
|
||||
|
||||
driver.find_element_by_xpath('//a[contains(.,"Advanced options")]').click()
|
||||
|
||||
if min_warning != None:
|
||||
|
||||
driver.find_element_by_id("text-min_warning").clear()
|
||||
driver.find_element_by_id("text-min_warning").send_keys(min_warning)
|
||||
|
||||
if max_warning != None:
|
||||
|
||||
driver.find_element_by_id("text-max_warning").clear()
|
||||
driver.find_element_by_id("text-max_warning").send_keys(min_warning)
|
||||
|
||||
if min_critical != None:
|
||||
|
||||
driver.find_element_by_id("text-min_critical").clear()
|
||||
driver.find_element_by_id("text-min_critical").send_keys(min_critical)
|
||||
|
||||
if max_critical != None:
|
||||
|
||||
driver.find_element_by_id("text-max_critical").clear()
|
||||
driver.find_element_by_id("text-max_critical").send_keys(max_critical)
|
||||
|
||||
if ip != None:
|
||||
|
||||
driver.find_element_by_id("text-ip_target").clear()
|
||||
driver.find_element_by_id("text-ip_target").send_keys(ip)
|
||||
|
||||
if component_group!= None and network_component!= None:
|
||||
Select(driver.find_element_by_id("network_component_group")).select_by_visible_text(component_group)
|
||||
Select(driver.find_element_by_id("network_component")).select_by_visible_text(network_component)
|
||||
|
||||
else:
|
||||
driver.find_element_by_id("text-name").clear()
|
||||
driver.find_element_by_id("text-name").send_keys(module_name)
|
||||
Select(driver.find_element_by_id("id_module_type")).select_by_visible_text(type)
|
||||
|
||||
if module_name != None:
|
||||
driver.find_element_by_id("text-name").clear()
|
||||
driver.find_element_by_id("text-name").send_keys(module_name)
|
||||
|
||||
if tag_name != None:
|
||||
|
||||
Select(driver.find_element_by_id("id_tag_available")).select_by_visible_text(tag_name)
|
||||
driver.find_element_by_xpath('//*[@id="right"]').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-crtbutton").click()
|
||||
|
||||
|
||||
def delete_module (driver,agent_name,module_name):
|
||||
|
||||
search_agent(driver,agent_name)
|
||||
driver.find_element_by_xpath('//ul[@class="mn"]/li/a/img[@data-title="Manage"]').click()
|
||||
driver.find_element_by_xpath('//ul[@class="mn"]/li/a/img[@data-title="Modules"]').click()
|
||||
|
||||
driver.find_element_by_id("text-search_string").clear()
|
||||
driver.find_element_by_id("text-search_string").send_keys(module_name)
|
||||
|
||||
driver.find_element_by_id("submit-filter").click()
|
||||
driver.find_element_by_id("checkbox-id_delete").click()
|
||||
driver.find_element_by_xpath('//*[@id="table2-1-9"]/a/img').click()
|
||||
|
||||
alert = driver.switch_to_alert()
|
||||
alert.accept()
|
||||
|
||||
def search_module (driver,agent_name,module_name):
|
||||
|
||||
search_agent(driver,agent_name)
|
||||
driver.find_element_by_xpath('//ul[@class="mn"]/li/a/img[@data-title="Manage"]').click()
|
||||
driver.find_element_by_xpath('//ul[@class="mn"]/li/a/img[@data-title="Modules"]').click()
|
||||
|
||||
driver.find_element_by_id("text-search_string").clear()
|
||||
driver.find_element_by_id("text-search_string").send_keys(module_name)
|
||||
|
||||
driver.find_element_by_id("submit-filter").click()
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
# -*- 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_report(driver,nombre,group_name,description=None):
|
||||
click_menu_element(driver,"Custom reporting")
|
||||
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(nombre)
|
||||
if group_name == "All":
|
||||
Select(driver.find_element_by_id("id_group")).select_by_visible_text(group_name)
|
||||
else:
|
||||
#TODO This will not work when choosing a group within a group within another group
|
||||
Select(driver.find_element_by_id("id_group")).select_by_visible_text(" "+group_name)
|
||||
|
||||
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-add").click()
|
||||
|
||||
def delete_report(driver,report_name):
|
||||
click_menu_element(driver,"Custom reporting")
|
||||
driver.find_element_by_id('text-search').clear()
|
||||
driver.find_element_by_id('text-search').send_keys(report_name)
|
||||
driver.find_element_by_id('submit-search_submit').click()
|
||||
driver.find_element_by_id('image-delete2').click()
|
||||
alert = driver.switch_to_alert()
|
||||
alert.accept()
|
|
@ -0,0 +1,85 @@
|
|||
# -*- 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 add_user_profile(driver,user_name,profile,group,tags=[]):
|
||||
click_menu_element(driver,"Users management")
|
||||
driver.find_element_by_css_selector("b").click()
|
||||
driver.find_element_by_id("text-filter_search").clear()
|
||||
driver.find_element_by_id("text-filter_search").send_keys(user_name)
|
||||
driver.find_element_by_id("submit-search").click()
|
||||
driver.find_element_by_xpath('//*[@id="table3-0-6"]/a[2]').click()
|
||||
Select(driver.find_element_by_id("assign_profile")).select_by_visible_text(profile)
|
||||
|
||||
|
||||
if group == "All":
|
||||
Select(driver.find_element_by_id("assign_group")).select_by_visible_text(group)
|
||||
else:
|
||||
#TODO This will not work when choosing a group within a group within another group
|
||||
Select(driver.find_element_by_id("assign_group")).select_by_visible_text(" "+group)
|
||||
|
||||
for tag in tags:
|
||||
Select(driver.find_element_by_id("assign_tags")).select_by_visible_text(tag)
|
||||
|
||||
#If we do not provide tags, we NEED to leave "Any" selected, otherwise we need to deselect it.
|
||||
if tags != []:
|
||||
Select(driver.find_element_by_id("assign_tags")).deselect_by_visible_text("Any")
|
||||
|
||||
driver.find_element_by_xpath('//*[@name="add"]').click()
|
||||
|
||||
|
||||
|
||||
def create_user(driver,user_name,userpwd,email=None,profile_list=None,is_admin=False):
|
||||
|
||||
u"""
|
||||
Profile list es una LISTA de TUPLAS:
|
||||
l = [("Chief Operator","All",[]),("Read Operator","Servers",["tag1","tag2"])]
|
||||
"""
|
||||
|
||||
click_menu_element(driver,"Users management")
|
||||
driver.find_element_by_id("submit-crt").click()
|
||||
driver.find_element_by_name("id_user").clear()
|
||||
driver.find_element_by_name("id_user").send_keys(user_name)
|
||||
driver.find_element_by_name("password_new").clear()
|
||||
driver.find_element_by_name("password_new").send_keys(userpwd)
|
||||
driver.find_element_by_name("password_confirm").clear()
|
||||
driver.find_element_by_name("password_confirm").send_keys(userpwd)
|
||||
driver.find_element_by_name("email").clear()
|
||||
|
||||
if is_admin == True:
|
||||
driver.find_element_by_id('radiobtn0001').click()
|
||||
|
||||
if is_admin == False:
|
||||
driver.find_element_by_id('radiobtn0002').click()
|
||||
|
||||
if email != None:
|
||||
driver.find_element_by_name("email").clear()
|
||||
driver.find_element_by_name("email").send_keys(email)
|
||||
driver.find_element_by_id("submit-crtbutton").click()
|
||||
|
||||
if profile_list != None:
|
||||
for profile_name,group_name,tag_list in profile_list:
|
||||
add_user_profile(driver,user_name,profile_name,group_name,tags=tag_list)
|
||||
|
||||
|
||||
def search_user(driver,user_name):
|
||||
click_menu_element(driver,"Users management")
|
||||
driver.find_element_by_css_selector("b").click()
|
||||
driver.find_element_by_id('text-filter_search').clear()
|
||||
driver.find_element_by_id("text-filter_search").send_keys(user_name)
|
||||
driver.find_element_by_id("submit-search").click()
|
||||
|
||||
|
||||
def activate_home_screen(driver,mode):
|
||||
|
||||
click_menu_element(driver,"Edit my user")
|
||||
Select(driver.find_element_by_id("section")).select_by_visible_text(mode)
|
||||
driver.find_element_by_id("submit-uptbutton").click()
|
||||
|
Loading…
Reference in New Issue