Repair function and add test B in Alerts.py
This commit is contained in:
parent
ba793b2f7b
commit
bb0300436c
|
@ -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
|
||||
|
@ -38,6 +38,38 @@ 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()
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
driver.find_element_by_id("text-name").clear()
|
||||
Select(driver.find_element_by_id("text-name")).send_keys(command_name)
|
||||
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)
|
||||
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"+i+"_description").clear()
|
||||
Select(driver.find_element_by_id("text-field"+i+"_description")).send_keys(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
|
||||
|
||||
if list_field_values != None:
|
||||
|
||||
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)
|
||||
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()
|
||||
|
||||
|
|
Loading…
Reference in New Issue