pandorafms/tests/console/PAN3.py

53 lines
2.0 KiB
Python
Raw Normal View History

2016-05-26 22:02:45 +02:00
# -*- coding: utf-8 -*-
from include.common_classes_60 import PandoraWebDriverTestCase
2016-07-11 13:37:10 +02:00
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
2016-05-26 22:02:45 +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
from selenium.common.exceptions import StaleElementReferenceException
2016-07-15 13:59:51 +02:00
from include.module_functions import *
2016-05-27 10:45:49 +02:00
import unittest, time, re
2016-05-26 22:02:45 +02:00
class PAN3(PandoraWebDriverTestCase):
test_name = u'PAN_3'
test_description = u'Creates a simple ICMP check against localhost and checks the result is 1'
tickets_associated = []
def test_pan3(self):
driver = self.driver
login(driver)
2016-06-15 11:11:08 +02:00
detect_and_pass_all_wizards(driver)
2016-07-15 13:59:51 +02:00
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")
2016-05-26 22:02:45 +02:00
driver.find_element_by_xpath('//*[@id="menu_tab"]//a[contains(@href,"ver_agente")]').click()
max_retries = 3
i = 1
element_text = ""
while (i <= max_retries): # Temporary workaround to weird StaleElementReferenceException exceptions due Javascript altering the DOM
try:
element_text = refresh_N_times_until_find_element(driver,5,"table1-1-7",how=By.ID).text
self.assertEqual("1", element_text.lstrip().rstrip()) # The lstrip.rstrip is done because if not, this error is raised: "'1' != u'1 '"
2016-05-27 10:45:49 +02:00
break
except StaleElementReferenceException as e_stale:
i = i+1
if i > max_retries:
2016-05-27 10:21:16 +02:00
self.verificationErrors.append(str(e_stale))
break
else:
next
except AssertionError as e:
self.verificationErrors.append(str(e))
2016-05-27 10:45:49 +02:00
break
2016-05-26 22:02:45 +02:00
if __name__ == "__main__":
unittest.main()