diff --git a/tests/console/Alerts.py b/tests/console/Alerts.py index c94e0e64c1..5a25a25953 100644 --- a/tests/console/Alerts.py +++ b/tests/console/Alerts.py @@ -16,7 +16,7 @@ class Alerts (PandoraWebDriverTestCase): test_name = u'Alerts tests' tickets_associated = [] - def test_create_new_email_action(self): + def test_A_create_new_email_action(self): u""" Create a new alert action using eMail command and check that create ok @@ -37,7 +37,39 @@ class Alerts (PandoraWebDriverTestCase): element = driver.find_element_by_xpath('//a[contains(.,"'+action_name+'")]') self.assertIsInstance(element,WebElement) + + + def test_B_create_new_action_command(self): + + u""" + Create a new command and then crreate a new action with this command. Check results + """ + action_name = gen_random_string(6) + command_name = gen_random_string(6) + + driver = self.driver + + list_values = ["_agent_","_agent_status","_agentdescription_"] + list_description=["agent name","status of agent","agent description"] + + create_new_command_to_alert(driver,command_name,"_agent_",list_field_description=list_description,list_field_values=list_values,description="command by test_B of Alerts") + + element = driver.find_element_by_xpath('//td[contains(.,"Successfully created")]') + self.assertIsInstance(element,WebElement) + + create_new_action_to_alert(driver,action_name,"Applications",command_name,field1="prueba@prueba.com",field2="Test",field3="This is a action with test B ") + + element = driver.find_element_by_xpath('//td[contains(.,"Successfully created")]') + self.assertIsInstance(element,WebElement) + + click_menu_element(driver,"Actions") + + element = driver.find_element_by_xpath('//a[contains(.,"'+action_name+'")]') + self.assertIsInstance(element,WebElement) + + driver.find_element_by_xpath('//a[contains(.,"'+action_name+'")]').click() + if __name__ == "__main__": unittest2.main() diff --git a/tests/console/include/alert_functions.py b/tests/console/include/alert_functions.py index 275f87ad3a..7867e7301f 100644 --- a/tests/console/include/alert_functions.py +++ b/tests/console/include/alert_functions.py @@ -70,30 +70,39 @@ def create_new_action_to_alert(driver,action_name,action_group,command,threshold driver.find_element_by_id("submit-create").click() -def create_new_command_to_alert(driver,command_name,command,list_field_description,list_field_values,description=None): +def create_new_command_to_alert(driver,command_name,command,list_field_description=None,list_field_values=None,description=None): click_menu_element(driver,"Commands") driver.find_element_by_id("submit-create").click() - - driver.find_element_by_id("text-name").clear() - Select(driver.find_element_by_id("text-name")).send_keys(command_name) + + time.sleep(3) + + driver.find_element_by_id("text-name").clear() + driver.find_element_by_xpath('//*[@id="text-name"]').send_keys(command_name) driver.find_element_by_id("textarea_command").clear() - Select(driver.find_element_by_id("textarea_command")).send_keys(command) + driver.find_element_by_id("textarea_command").send_keys(command) if description != None: driver.find_element_by_id("textarea_description").clear() - Select(driver.find_element_by_id("textarea_description")).send_keys(description) - i=1 - for field_description in list_field_description: - driver.find_element_by_id("text-field"+i+"_description").clear() - Select(driver.find_element_by_id("text-field"+i+"_description")).send_keys(field_description) + driver.find_element_by_id("textarea_description").send_keys(description) + + if list_field_description != None: + + i=1 + for field_description in list_field_description: + driver.find_element_by_id("text-field"+str(i)+"_description").clear() + driver.find_element_by_id("text-field"+str(i)+"_description").send_keys(field_description) + i=i+1 - i=1 - for field_value in list_field_values: - driver.find_element_by_id("text-field"+i+"_description").clear() - Select(driver.find_element_by_id("text-field"+i+"_description")).send_keys(field_value) + if list_field_values != None: + + i=1 + for field_value in list_field_values: + driver.find_element_by_id("text-field"+str(i)+"_values").clear() + driver.find_element_by_id("text-field"+str(i)+"_values").send_keys(field_value) + i=i+1 driver.find_element_by_id("submit-create").click()