pandorafms/tests/console/Misc.py

74 lines
3.1 KiB
Python
Raw Normal View History

2016-07-05 12:01:20 +02:00
# -*- coding: utf-8 -*-
2016-08-19 15:48:02 +02:00
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
2016-08-19 15:48:02 +02:00
from include.reports_functions import create_report, delete_report
from include.user_functions import create_user
from include.agent_functions import create_agent
from include.module_functions import create_module
from include.event_functions import *
2016-07-04 16:20:47 +02:00
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
2016-07-04 16:45:21 +02:00
from selenium.common.exceptions import StaleElementReferenceException, NoSuchElementException
2016-07-19 12:55:15 +02:00
from selenium.common.exceptions import NoAlertPresentException
2016-07-19 12:12:31 +02:00
from selenium.webdriver.remote.webelement import WebElement
import unittest2, time, re
2017-01-02 12:06:12 +01:00
import logging
2016-07-04 16:20:47 +02:00
class Miscellaneous (PandoraWebDriverTestCase):
2016-07-04 16:20:47 +02:00
test_name = u'Miscellaneous'
2016-07-05 11:59:53 +02:00
tickets_associated = []
2016-07-04 16:20:47 +02:00
def test_japanese_characters(self):
u"""
Creates an agent and a module with japanese characters and test if the event list show the characters properly
"""
2017-01-02 12:06:12 +01:00
logging.basicConfig(filename="Misc.log", level=logging.INFO, filemode='w')
2016-07-04 16:20:47 +02:00
driver = self.driver
self.login()
2016-07-04 16:20:47 +02:00
detect_and_pass_all_wizards(driver)
2016-07-05 11:59:53 +02:00
create_agent(driver,u"次のライセンスに基づいていま")
#Create module
2016-07-15 13:59:51 +02:00
create_module("network_server",driver,agent_name=u"次のライセンスに基づいていま",module_name=u"管理者ガイド",component_group="Network Management",network_component="Host Alive",ip="192.168.50.50")
#Create alert
driver.find_element_by_xpath('//ul[@class="mn"]/li/a/img[@data-title="Alerts"]').click()
2016-07-04 16:20:47 +02:00
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()
2016-07-05 11:59:53 +02:00
#Force alert
2016-07-04 16:20:47 +02:00
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()
2016-07-04 18:35:13 +02:00
time.sleep(10)
2016-07-05 11:59:53 +02:00
#Search events of our agent
2016-08-17 17:14:25 +02:00
search_events(driver,agent_name=u"次のライセンスに基づいていま",module_name=u"管理者ガイド")
2016-07-04 16:20:47 +02:00
#Check that there are japanese characters present on the event
2017-01-02 12:06:12 +01:00
element=driver.find_element_by_xpath(u'//a[contains(.,"Alert fired (Critical condition) assigned to (管理者ガイド)")]')
self.assertIsInstance(element,WebElement)
2016-07-04 16:20:47 +02:00
2017-01-02 12:06:12 +01:00
logging.info("test_japanese_characters is correct")
2016-07-04 16:20:47 +02:00
if __name__ == "__main__":
unittest2.main()
2016-07-05 11:59:53 +02:00