From 83ebe50c0a49c2f5e9890d724e4560ba60fd3c1c Mon Sep 17 00:00:00 2001 From: Prachi Yadav Date: Wed, 21 Dec 2016 10:24:49 +0530 Subject: [PATCH 1/5] EAP Power Operation related Test case Added --- tests/test_eap_operations.py | 40 +++++++++++++++ views/eap_operations.py | 98 ++++++++++++++++++++++++++++++++++++ 2 files changed, 138 insertions(+) create mode 100644 tests/test_eap_operations.py create mode 100644 views/eap_operations.py diff --git a/tests/test_eap_operations.py b/tests/test_eap_operations.py new file mode 100644 index 0000000..cb9791f --- /dev/null +++ b/tests/test_eap_operations.py @@ -0,0 +1,40 @@ +import pytest +from common.session import session +from views.eap_operations import eap_operations + +@pytest.fixture (scope='session') +def web_session(request): + web_session = session(add_provider=True) + web_session.logger.info("OPR010, OPR011, OPR012, OPR013, OPR014, OPR015: Operations on Single JBoss EAP in a server group") + + def closeSession(): + web_session.logger.info("Close browser session") + web_session.close_web_driver() + + request.addfinalizer(closeSession) + + return web_session + +def test_eap_stop(web_session): + web_session.logger.info("Begin eap Stop Test") + assert eap_operations(web_session).stop_eap() + +def test_eap_restart(web_session): + web_session.logger.info("Begin eap Restart Test") + assert eap_operations(web_session).restart_eap() + +def test_eap_gracefull_stop(web_session): + web_session.logger.info("Begin eap Gracefull Stop Test") + assert eap_operations(web_session).gracefull_stop_eap() + +def test_eap_reload(web_session): + web_session.logger.info("Begin eap Reload Test") + assert eap_operations(web_session).reload_eap() + +def test_eap_suspend(web_session): + web_session.logger.info("Begin eap Suspend Test") + assert eap_operations(web_session).suspend_eap() + +def test_eap_resume(web_session): + web_session.logger.info("Begin eap Reume Test") + assert eap_operations(web_session).resume_eap() \ No newline at end of file diff --git a/views/eap_operations.py b/views/eap_operations.py new file mode 100644 index 0000000..5666729 --- /dev/null +++ b/views/eap_operations.py @@ -0,0 +1,98 @@ +from common.ui_utils import ui_utils +from selenium.webdriver.support.ui import WebDriverWait +from selenium.webdriver.common.by import By +from time import sleep +from selenium import webdriver +from selenium.webdriver.common.keys import Keys +''' + +Created on September 22, 2016 + +@author: pyadav + +''' + +class eap_operations(): + + web_session = None + + def __init__(self, web_session): + + self.web_session = web_session + self.web_driver = web_session.web_driver + + def stop_eap(self): + self.web_session.web_driver.get("{}/middleware_server/show_list".format(self.web_session.MIQ_URL)) + assert ui_utils(self.web_session).waitForTextOnPage("Server Name", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'JBoss EAP')]").click() + assert ui_utils(self.web_session).waitForTextOnPage("Properties",15) + self.web_session.web_driver.find_element_by_xpath("//button[@title='Power']").click() + self.web_session.web_driver.find_element_by_xpath("//a[contains(@id,'stop')]").click() + ui_utils(self.web_session).accept_alert(20) + assert ui_utils(self.web_session).waitForTextOnPage("Stop initiated for selected server(s)", 30) + return True + + def restart_eap(self): + self.web_session.web_driver.get("{}/middleware_server/show_list".format(self.web_session.MIQ_URL)) + assert ui_utils(self.web_session).waitForTextOnPage("Server Name", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'JBoss EAP')]").click() + assert ui_utils(self.web_session).waitForTextOnPage("Properties", 15) + self.web_session.web_driver.find_element_by_xpath("//button[@title='Power']").click() + self.web_session.web_driver.find_element_by_xpath("//a[contains(@id,'restart')]").click() + ui_utils(self.web_session).accept_alert(20) + assert ui_utils(self.web_session).waitForTextOnPage("Restart initiated for selected server(s)", 15) + return True + + def gracefull_stop_eap(self): + self.web_session.web_driver.get("{}/middleware_server/show_list".format(self.web_session.MIQ_URL)) + assert ui_utils(self.web_session).waitForTextOnPage("Server Name", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'JBoss EAP')]").click() + assert ui_utils(self.web_session).waitForTextOnPage("Properties", 15) + self.web_session.web_driver.find_element_by_xpath("//button[@title='Power']").click() + self.web_session.web_driver.find_element_by_xpath("//a[@title='Gracefully shut this server down']").click() + ui_utils(self.web_session).sleep(10) + self.web_session.web_driver.find_element_by_xpath("//button[@title='Shutdown']").click() + assert ui_utils(self.web_session).waitForTextOnPage("Shutdown initiated for selected server(s)", 15) + return True + + def reload_eap(self): + self.web_session.web_driver.get("{}/middleware_server/show_list".format(self.web_session.MIQ_URL)) + assert ui_utils(self.web_session).waitForTextOnPage("Server Name", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'JBoss EAP')]").click() + assert ui_utils(self.web_session).waitForTextOnPage("Properties", 15) + self.web_session.web_driver.find_element_by_xpath("//button[@title='Power']").click() + self.web_session.web_driver.find_element_by_xpath("//a[contains(@id,'reload')]").click() + ui_utils(self.web_session).accept_alert(20) + assert ui_utils(self.web_session).waitForTextOnPage("Reload initiated for selected server(s)", 15) + + return True + + def suspend_eap(self): + self.web_session.web_driver.get("{}/middleware_server/show_list".format(self.web_session.MIQ_URL)) + assert ui_utils(self.web_session).waitForTextOnPage("Server Name", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'JBoss EAP')]").click() + assert ui_utils(self.web_session).waitForTextOnPage("Properties", 15) + self.web_session.web_driver.find_element_by_xpath("//button[@title='Power']").click() + self.web_session.web_driver.find_element_by_xpath("//a[contains(@id,'suspend')]").click() + ui_utils(self.web_session).sleep(10) + self.web_session.web_driver.find_element_by_xpath("//button[@alt='Suspend']").click() + assert ui_utils(self.web_session).waitForTextOnPage("Suspend initiated for selected server(s)", 15) + return True + + def resume_eap(self): + self.web_session.web_driver.get("{}/middleware_server/show_list".format(self.web_session.MIQ_URL)) + assert ui_utils(self.web_session).waitForTextOnPage("Server Name", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'JBoss EAP')]").click() + assert ui_utils(self.web_session).waitForTextOnPage("Properties", 15) + self.web_session.web_driver.find_element_by_xpath("//button[@title='Power']").click() + self.web_session.web_driver.find_element_by_xpath("//a[contains(@id,'resume')]").click() + ui_utils(self.web_session).accept_alert(20) + assert ui_utils(self.web_session).waitForTextOnPage("Resume initiated for selected server(s)", 15) + return True + + + + + + + From d491ae685b1e94741a83a90d1d5428eef1a6a6a5 Mon Sep 17 00:00:00 2001 From: Prachi Yadav Date: Wed, 28 Dec 2016 23:26:09 +0530 Subject: [PATCH 2/5] edited test case for domain server group --- tests/test_eap_operations.py | 4 +- views/eap_operations.py | 71 ++++++++++++++++++++++++++++++------ 2 files changed, 61 insertions(+), 14 deletions(-) diff --git a/tests/test_eap_operations.py b/tests/test_eap_operations.py index cb9791f..de303d1 100644 --- a/tests/test_eap_operations.py +++ b/tests/test_eap_operations.py @@ -12,7 +12,6 @@ def closeSession(): web_session.close_web_driver() request.addfinalizer(closeSession) - return web_session def test_eap_stop(web_session): @@ -37,4 +36,5 @@ def test_eap_suspend(web_session): def test_eap_resume(web_session): web_session.logger.info("Begin eap Reume Test") - assert eap_operations(web_session).resume_eap() \ No newline at end of file + assert eap_operations(web_session).resume_eap() + diff --git a/views/eap_operations.py b/views/eap_operations.py index 5666729..2b43716 100644 --- a/views/eap_operations.py +++ b/views/eap_operations.py @@ -22,41 +22,72 @@ def __init__(self, web_session): self.web_driver = web_session.web_driver def stop_eap(self): - self.web_session.web_driver.get("{}/middleware_server/show_list".format(self.web_session.MIQ_URL)) + self.web_session.web_driver.get("{}/middleware_domain/show_list".format(self.web_session.MIQ_URL)) + assert ui_utils(self.web_session).waitForTextOnPage("Domain Name ",15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'master')]").click() + assert ui_utils(self.web_session).waitForTextOnPage("master (Summary)",15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'Middleware Server Groups')]").click() + assert ui_utils(self.web_session).waitForTextOnPage(" Server Group Name ", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'main-server-group')]").click() + assert ui_utils(self.web_session).waitForTextOnPage("Properties ", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'Middleware Servers')]") assert ui_utils(self.web_session).waitForTextOnPage("Server Name", 15) - self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'JBoss EAP')]").click() + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'server-one')]").click() assert ui_utils(self.web_session).waitForTextOnPage("Properties",15) self.web_session.web_driver.find_element_by_xpath("//button[@title='Power']").click() - self.web_session.web_driver.find_element_by_xpath("//a[contains(@id,'stop')]").click() + self.web_session.web_driver.find_element_by_xpath("//a[@title='Stop this server']") .click() ui_utils(self.web_session).accept_alert(20) assert ui_utils(self.web_session).waitForTextOnPage("Stop initiated for selected server(s)", 30) return True def restart_eap(self): - self.web_session.web_driver.get("{}/middleware_server/show_list".format(self.web_session.MIQ_URL)) + self.web_session.web_driver.get("{}/middleware_domain/show_list".format(self.web_session.MIQ_URL)) + assert ui_utils(self.web_session).waitForTextOnPage("Domain Name ", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'master')]").click() + assert ui_utils(self.web_session).waitForTextOnPage("master (Summary)", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'Middleware Server Groups')]").click() + assert ui_utils(self.web_session).waitForTextOnPage(" Server Group Name ", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'main-server-group')]").click() + assert ui_utils(self.web_session).waitForTextOnPage("Properties ", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'Middleware Servers')]") assert ui_utils(self.web_session).waitForTextOnPage("Server Name", 15) self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'JBoss EAP')]").click() assert ui_utils(self.web_session).waitForTextOnPage("Properties", 15) self.web_session.web_driver.find_element_by_xpath("//button[@title='Power']").click() - self.web_session.web_driver.find_element_by_xpath("//a[contains(@id,'restart')]").click() + self.web_session.web_driver.find_element_by_xpath("//a[@title='Restart this server']").click() ui_utils(self.web_session).accept_alert(20) assert ui_utils(self.web_session).waitForTextOnPage("Restart initiated for selected server(s)", 15) return True def gracefull_stop_eap(self): - self.web_session.web_driver.get("{}/middleware_server/show_list".format(self.web_session.MIQ_URL)) + self.web_session.web_driver.get("{}/middleware_domain/show_list".format(self.web_session.MIQ_URL)) + assert ui_utils(self.web_session).waitForTextOnPage("Domain Name ", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'master')]").click() + assert ui_utils(self.web_session).waitForTextOnPage("master (Summary)", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'Middleware Server Groups')]").click() + assert ui_utils(self.web_session).waitForTextOnPage(" Server Group Name ", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'main-server-group')]").click() + assert ui_utils(self.web_session).waitForTextOnPage("Properties ", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'Middleware Servers')]") assert ui_utils(self.web_session).waitForTextOnPage("Server Name", 15) self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'JBoss EAP')]").click() assert ui_utils(self.web_session).waitForTextOnPage("Properties", 15) self.web_session.web_driver.find_element_by_xpath("//button[@title='Power']").click() - self.web_session.web_driver.find_element_by_xpath("//a[@title='Gracefully shut this server down']").click() - ui_utils(self.web_session).sleep(10) - self.web_session.web_driver.find_element_by_xpath("//button[@title='Shutdown']").click() + self.web_session.web_driver.find_element_by_xpath("//a[@title='Kill this server']").click() + ui_utils(self.web_session).accept_alert(20) assert ui_utils(self.web_session).waitForTextOnPage("Shutdown initiated for selected server(s)", 15) return True def reload_eap(self): - self.web_session.web_driver.get("{}/middleware_server/show_list".format(self.web_session.MIQ_URL)) + self.web_session.web_driver.get("{}/middleware_domain/show_list".format(self.web_session.MIQ_URL)) + assert ui_utils(self.web_session).waitForTextOnPage("Domain Name ", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'master')]").click() + assert ui_utils(self.web_session).waitForTextOnPage("master (Summary)", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'Middleware Server Groups')]").click() + assert ui_utils(self.web_session).waitForTextOnPage(" Server Group Name ", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'main-server-group')]").click() + assert ui_utils(self.web_session).waitForTextOnPage("Properties ", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'Middleware Servers')]") assert ui_utils(self.web_session).waitForTextOnPage("Server Name", 15) self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'JBoss EAP')]").click() assert ui_utils(self.web_session).waitForTextOnPage("Properties", 15) @@ -68,7 +99,15 @@ def reload_eap(self): return True def suspend_eap(self): - self.web_session.web_driver.get("{}/middleware_server/show_list".format(self.web_session.MIQ_URL)) + self.web_session.web_driver.get("{}/middleware_domain/show_list".format(self.web_session.MIQ_URL)) + assert ui_utils(self.web_session).waitForTextOnPage("Domain Name ", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'master')]").click() + assert ui_utils(self.web_session).waitForTextOnPage("master (Summary)", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'Middleware Server Groups')]").click() + assert ui_utils(self.web_session).waitForTextOnPage(" Server Group Name ", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'main-server-group')]").click() + assert ui_utils(self.web_session).waitForTextOnPage("Properties ", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'Middleware Servers')]") assert ui_utils(self.web_session).waitForTextOnPage("Server Name", 15) self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'JBoss EAP')]").click() assert ui_utils(self.web_session).waitForTextOnPage("Properties", 15) @@ -80,7 +119,15 @@ def suspend_eap(self): return True def resume_eap(self): - self.web_session.web_driver.get("{}/middleware_server/show_list".format(self.web_session.MIQ_URL)) + self.web_session.web_driver.get("{}/middleware_domain/show_list".format(self.web_session.MIQ_URL)) + assert ui_utils(self.web_session).waitForTextOnPage("Domain Name ", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'master')]").click() + assert ui_utils(self.web_session).waitForTextOnPage("master (Summary)", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'Middleware Server Groups')]").click() + assert ui_utils(self.web_session).waitForTextOnPage(" Server Group Name ", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'main-server-group')]").click() + assert ui_utils(self.web_session).waitForTextOnPage("Properties ", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'Middleware Servers')]") assert ui_utils(self.web_session).waitForTextOnPage("Server Name", 15) self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'JBoss EAP')]").click() assert ui_utils(self.web_session).waitForTextOnPage("Properties", 15) From d436d87413c8a9878aa5eba9e624e59b91510376 Mon Sep 17 00:00:00 2001 From: Prachi Yadav Date: Mon, 2 Jan 2017 15:56:11 +0530 Subject: [PATCH 3/5] edited Test and added kill EAP Test --- tests/test_eap_operations.py | 28 +++++++--- views/eap_operations.py | 104 ++++++++++------------------------- 2 files changed, 49 insertions(+), 83 deletions(-) diff --git a/tests/test_eap_operations.py b/tests/test_eap_operations.py index de303d1..d587b9c 100644 --- a/tests/test_eap_operations.py +++ b/tests/test_eap_operations.py @@ -12,8 +12,10 @@ def closeSession(): web_session.close_web_driver() request.addfinalizer(closeSession) + return web_session + def test_eap_stop(web_session): web_session.logger.info("Begin eap Stop Test") assert eap_operations(web_session).stop_eap() @@ -22,19 +24,31 @@ def test_eap_restart(web_session): web_session.logger.info("Begin eap Restart Test") assert eap_operations(web_session).restart_eap() -def test_eap_gracefull_stop(web_session): - web_session.logger.info("Begin eap Gracefull Stop Test") - assert eap_operations(web_session).gracefull_stop_eap() +def test_eap_kill(web_session): + web_session.logger.info("Begin eap Kill Test") + assert eap_operations(web_session).kill_eap() -def test_eap_reload(web_session): - web_session.logger.info("Begin eap Reload Test") - assert eap_operations(web_session).reload_eap() +def test_eap_start(web_session): + web_session.logger.info("Begin eap Start Test") + assert eap_operations(web_session).start_eap() def test_eap_suspend(web_session): web_session.logger.info("Begin eap Suspend Test") assert eap_operations(web_session).suspend_eap() def test_eap_resume(web_session): - web_session.logger.info("Begin eap Reume Test") + web_session.logger.info("Begin eap Resume Test") assert eap_operations(web_session).resume_eap() +def test_eap_reload(web_session): + web_session.logger.info("Begin eap Reload Test") + assert eap_operations(web_session).reload_eap() + + + + + + + + + diff --git a/views/eap_operations.py b/views/eap_operations.py index 2b43716..d42819f 100644 --- a/views/eap_operations.py +++ b/views/eap_operations.py @@ -21,97 +21,53 @@ def __init__(self, web_session): self.web_session = web_session self.web_driver = web_session.web_driver - def stop_eap(self): + def eap_power(self): self.web_session.web_driver.get("{}/middleware_domain/show_list".format(self.web_session.MIQ_URL)) - assert ui_utils(self.web_session).waitForTextOnPage("Domain Name ",15) + assert ui_utils(self.web_session).waitForTextOnPage("Middleware Domains", 15) self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'master')]").click() - assert ui_utils(self.web_session).waitForTextOnPage("master (Summary)",15) + assert ui_utils(self.web_session).waitForTextOnPage("master (Summary)", 15) self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'Middleware Server Groups')]").click() - assert ui_utils(self.web_session).waitForTextOnPage(" Server Group Name ", 15) + assert ui_utils(self.web_session).waitForTextOnPage("Server Group Name", 15) self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'main-server-group')]").click() - assert ui_utils(self.web_session).waitForTextOnPage("Properties ", 15) - self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'Middleware Servers')]") + assert ui_utils(self.web_session).waitForTextOnPage("main-server-group (Summary)", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'Middleware Servers')]").click() assert ui_utils(self.web_session).waitForTextOnPage("Server Name", 15) self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'server-one')]").click() - assert ui_utils(self.web_session).waitForTextOnPage("Properties",15) + assert ui_utils(self.web_session).waitForTextOnPage("Properties", 15) self.web_session.web_driver.find_element_by_xpath("//button[@title='Power']").click() - self.web_session.web_driver.find_element_by_xpath("//a[@title='Stop this server']") .click() + + + + def stop_eap(self): + self.eap_power() + self.web_session.web_driver.find_element_by_xpath("//a[@title='Stop this server']").click() ui_utils(self.web_session).accept_alert(20) assert ui_utils(self.web_session).waitForTextOnPage("Stop initiated for selected server(s)", 30) return True def restart_eap(self): - self.web_session.web_driver.get("{}/middleware_domain/show_list".format(self.web_session.MIQ_URL)) - assert ui_utils(self.web_session).waitForTextOnPage("Domain Name ", 15) - self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'master')]").click() - assert ui_utils(self.web_session).waitForTextOnPage("master (Summary)", 15) - self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'Middleware Server Groups')]").click() - assert ui_utils(self.web_session).waitForTextOnPage(" Server Group Name ", 15) - self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'main-server-group')]").click() - assert ui_utils(self.web_session).waitForTextOnPage("Properties ", 15) - self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'Middleware Servers')]") - assert ui_utils(self.web_session).waitForTextOnPage("Server Name", 15) - self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'JBoss EAP')]").click() - assert ui_utils(self.web_session).waitForTextOnPage("Properties", 15) - self.web_session.web_driver.find_element_by_xpath("//button[@title='Power']").click() + self.eap_power() self.web_session.web_driver.find_element_by_xpath("//a[@title='Restart this server']").click() ui_utils(self.web_session).accept_alert(20) assert ui_utils(self.web_session).waitForTextOnPage("Restart initiated for selected server(s)", 15) return True - def gracefull_stop_eap(self): - self.web_session.web_driver.get("{}/middleware_domain/show_list".format(self.web_session.MIQ_URL)) - assert ui_utils(self.web_session).waitForTextOnPage("Domain Name ", 15) - self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'master')]").click() - assert ui_utils(self.web_session).waitForTextOnPage("master (Summary)", 15) - self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'Middleware Server Groups')]").click() - assert ui_utils(self.web_session).waitForTextOnPage(" Server Group Name ", 15) - self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'main-server-group')]").click() - assert ui_utils(self.web_session).waitForTextOnPage("Properties ", 15) - self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'Middleware Servers')]") - assert ui_utils(self.web_session).waitForTextOnPage("Server Name", 15) - self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'JBoss EAP')]").click() - assert ui_utils(self.web_session).waitForTextOnPage("Properties", 15) - self.web_session.web_driver.find_element_by_xpath("//button[@title='Power']").click() + def kill_eap(self): + self.eap_power() self.web_session.web_driver.find_element_by_xpath("//a[@title='Kill this server']").click() ui_utils(self.web_session).accept_alert(20) - assert ui_utils(self.web_session).waitForTextOnPage("Shutdown initiated for selected server(s)", 15) + assert ui_utils(self.web_session).waitForTextOnPage("Kill initiated for selected server(s)", 15) return True def reload_eap(self): - self.web_session.web_driver.get("{}/middleware_domain/show_list".format(self.web_session.MIQ_URL)) - assert ui_utils(self.web_session).waitForTextOnPage("Domain Name ", 15) - self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'master')]").click() - assert ui_utils(self.web_session).waitForTextOnPage("master (Summary)", 15) - self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'Middleware Server Groups')]").click() - assert ui_utils(self.web_session).waitForTextOnPage(" Server Group Name ", 15) - self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'main-server-group')]").click() - assert ui_utils(self.web_session).waitForTextOnPage("Properties ", 15) - self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'Middleware Servers')]") - assert ui_utils(self.web_session).waitForTextOnPage("Server Name", 15) - self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'JBoss EAP')]").click() - assert ui_utils(self.web_session).waitForTextOnPage("Properties", 15) - self.web_session.web_driver.find_element_by_xpath("//button[@title='Power']").click() + self.eap_power() self.web_session.web_driver.find_element_by_xpath("//a[contains(@id,'reload')]").click() ui_utils(self.web_session).accept_alert(20) assert ui_utils(self.web_session).waitForTextOnPage("Reload initiated for selected server(s)", 15) - return True def suspend_eap(self): - self.web_session.web_driver.get("{}/middleware_domain/show_list".format(self.web_session.MIQ_URL)) - assert ui_utils(self.web_session).waitForTextOnPage("Domain Name ", 15) - self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'master')]").click() - assert ui_utils(self.web_session).waitForTextOnPage("master (Summary)", 15) - self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'Middleware Server Groups')]").click() - assert ui_utils(self.web_session).waitForTextOnPage(" Server Group Name ", 15) - self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'main-server-group')]").click() - assert ui_utils(self.web_session).waitForTextOnPage("Properties ", 15) - self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'Middleware Servers')]") - assert ui_utils(self.web_session).waitForTextOnPage("Server Name", 15) - self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'JBoss EAP')]").click() - assert ui_utils(self.web_session).waitForTextOnPage("Properties", 15) - self.web_session.web_driver.find_element_by_xpath("//button[@title='Power']").click() + self.eap_power() self.web_session.web_driver.find_element_by_xpath("//a[contains(@id,'suspend')]").click() ui_utils(self.web_session).sleep(10) self.web_session.web_driver.find_element_by_xpath("//button[@alt='Suspend']").click() @@ -119,24 +75,20 @@ def suspend_eap(self): return True def resume_eap(self): - self.web_session.web_driver.get("{}/middleware_domain/show_list".format(self.web_session.MIQ_URL)) - assert ui_utils(self.web_session).waitForTextOnPage("Domain Name ", 15) - self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'master')]").click() - assert ui_utils(self.web_session).waitForTextOnPage("master (Summary)", 15) - self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'Middleware Server Groups')]").click() - assert ui_utils(self.web_session).waitForTextOnPage(" Server Group Name ", 15) - self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'main-server-group')]").click() - assert ui_utils(self.web_session).waitForTextOnPage("Properties ", 15) - self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'Middleware Servers')]") - assert ui_utils(self.web_session).waitForTextOnPage("Server Name", 15) - self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'JBoss EAP')]").click() - assert ui_utils(self.web_session).waitForTextOnPage("Properties", 15) - self.web_session.web_driver.find_element_by_xpath("//button[@title='Power']").click() + self.eap_power() self.web_session.web_driver.find_element_by_xpath("//a[contains(@id,'resume')]").click() ui_utils(self.web_session).accept_alert(20) + ui_utils(self.web_session).sleep(10) assert ui_utils(self.web_session).waitForTextOnPage("Resume initiated for selected server(s)", 15) return True + def start_eap(self): + self.eap_power() + self.web_session.web_driver.find_element_by_xpath("//a[contains(@title,'Start this server')]").click() + ui_utils(self.web_session).accept_alert(20) + assert ui_utils(self.web_session).waitForTextOnPage("Resume initiated for selected server(s)", 20) + return True + From 06ccaec8f49bb337fb62dac7c4b28744eae5ca61 Mon Sep 17 00:00:00 2001 From: Prachi Yadav Date: Wed, 4 Jan 2017 14:01:33 +0530 Subject: [PATCH 4/5] reactored and changed function name as per sugestion --- tests/test_domain_mode_eap_operations.py | 54 +++++++++++++ views/domain_mode_eap_operations.py | 98 ++++++++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100644 tests/test_domain_mode_eap_operations.py create mode 100644 views/domain_mode_eap_operations.py diff --git a/tests/test_domain_mode_eap_operations.py b/tests/test_domain_mode_eap_operations.py new file mode 100644 index 0000000..ac94c08 --- /dev/null +++ b/tests/test_domain_mode_eap_operations.py @@ -0,0 +1,54 @@ +import pytest +from common.session import session +from views.domain_mode_eap_operations import domain_mode_eap_operations + +@pytest.fixture (scope='session') +def web_session(request): + web_session = session(add_provider=True) + web_session.logger.info("OPR010, OPR011, OPR012, OPR013, OPR014, OPR015: Operations on Single JBoss EAP in a server group") + + def closeSession(): + web_session.logger.info("Close browser session") + web_session.close_web_driver() + + request.addfinalizer(closeSession) + + return web_session + + +def test_domain_mode_eap_stop(web_session): + web_session.logger.info("Begin eap Stop Test") + assert domain_mode_eap_operations(web_session).stop_eap() + +def test_eap_start(web_session): + web_session.logger.info("Begin eap Start Test") + assert domain_mode_eap_operations(web_session).start_eap() + +def test_eap_restart(web_session): + web_session.logger.info("Begin eap Restart Test") + assert domain_mode_eap_operations(web_session).restart_eap() + +def test_eap_kill(web_session): + web_session.logger.info("Begin eap Kill Test") + assert domain_mode_eap_operations(web_session).kill_eap() + +def test_eap_suspend(web_session): + web_session.logger.info("Begin eap Suspend Test") + assert domain_mode_eap_operations(web_session).suspend_eap() + +def test_eap_resume(web_session): + web_session.logger.info("Begin eap Resume Test") + assert domain_mode_eap_operations(web_session).resume_eap() + +def test_eap_reload(web_session): + web_session.logger.info("Begin eap Reload Test") + assert domain_mode_eap_operations(web_session).reload_eap() + + + + + + + + + diff --git a/views/domain_mode_eap_operations.py b/views/domain_mode_eap_operations.py new file mode 100644 index 0000000..9d99251 --- /dev/null +++ b/views/domain_mode_eap_operations.py @@ -0,0 +1,98 @@ +from common.ui_utils import ui_utils +from selenium.webdriver.support.ui import WebDriverWait +from selenium.webdriver.common.by import By +from time import sleep +from selenium import webdriver +from selenium.webdriver.common.keys import Keys +''' + +Created on December 15, 2016 + +@author: pyadav + +''' + +class domain_mode_eap_operations(): + + web_session = None + + def __init__(self, web_session): + + self.web_session = web_session + self.web_driver = web_session.web_driver + + def find_domain_mode_eap_power(self): + self.web_session.web_driver.get("{}/middleware_domain/show_list".format(self.web_session.MIQ_URL)) + assert ui_utils(self.web_session).waitForTextOnPage("Middleware Domains", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'master')]").click() + assert ui_utils(self.web_session).waitForTextOnPage("master (Summary)", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'Middleware Server Groups')]").click() + assert ui_utils(self.web_session).waitForTextOnPage("Server Group Name", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'main-server-group')]").click() + assert ui_utils(self.web_session).waitForTextOnPage("main-server-group (Summary)", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'Middleware Servers')]").click() + assert ui_utils(self.web_session).waitForTextOnPage("Server Name", 15) + self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'server-one')]").click() + assert ui_utils(self.web_session).waitForTextOnPage("Properties", 15) + self.web_session.web_driver.find_element_by_xpath("//button[@title='Power']").click() + + + + def stop_eap(self): + self.find_domain_mode_eap_power() + self.web_session.web_driver.find_element_by_xpath("//a[@title='Stop this server']").click() + ui_utils(self.web_session).accept_alert(20) + assert ui_utils(self.web_session).waitForTextOnPage("Stop initiated for selected server(s)", 30) + return True + + def restart_eap(self): + self.find_domain_mode_eap_power() + self.web_session.web_driver.find_element_by_xpath("//a[@title='Restart this server']").click() + ui_utils(self.web_session).accept_alert(20) + assert ui_utils(self.web_session).waitForTextOnPage("Restart initiated for selected server(s)", 15) + return True + + def kill_eap(self): + self.find_domain_mode_eap_power() + self.web_session.web_driver.find_element_by_xpath("//a[@title='Kill this server']").click() + ui_utils(self.web_session).accept_alert(20) + assert ui_utils(self.web_session).waitForTextOnPage("Kill initiated for selected server(s)", 15) + self.start_eap() #Start EAP to perform other operation Tests + return True + + def reload_eap(self): + self.find_domain_mode_eap_power() + self.web_session.web_driver.find_element_by_xpath("//a[contains(@id,'reload')]").click() + ui_utils(self.web_session).accept_alert(20) + assert ui_utils(self.web_session).waitForTextOnPage("Reload initiated for selected server(s)", 15) + return True + + def suspend_eap(self): + self.find_domain_mode_eap_power() + self.web_session.web_driver.find_element_by_xpath("//a[contains(@id,'suspend')]").click() + ui_utils(self.web_session).sleep(10) + self.web_session.web_driver.find_element_by_xpath("//button[@alt='Suspend']").click() + assert ui_utils(self.web_session).waitForTextOnPage("Suspend initiated for selected server(s)", 15) + return True + + def resume_eap(self): + self.find_domain_mode_eap_power() + self.web_session.web_driver.find_element_by_xpath("//a[contains(@id,'resume')]").click() + ui_utils(self.web_session).accept_alert(20) + ui_utils(self.web_session).sleep(10) + assert ui_utils(self.web_session).waitForTextOnPage("Resume initiated for selected server(s)", 15) + return True + + def start_eap(self): + self.find_domain_mode_eap_power() + self.web_session.web_driver.find_element_by_xpath("//a[contains(@title,'Start this server')]").click() + ui_utils(self.web_session).accept_alert(20) + assert ui_utils(self.web_session).waitForTextOnPage("Start initiated for selected server(s)", 20) + return True + + + + + + + From 893eb789a9b1eeb4be6d9c2b51c9126be4c6dce2 Mon Sep 17 00:00:00 2001 From: Prachi Yadav Date: Wed, 4 Jan 2017 20:33:54 +0530 Subject: [PATCH 5/5] added Test cases and refactored as per sugestion --- tests/test_eap_operations.py | 54 -------------------- views/eap_operations.py | 97 ------------------------------------ 2 files changed, 151 deletions(-) delete mode 100644 tests/test_eap_operations.py delete mode 100644 views/eap_operations.py diff --git a/tests/test_eap_operations.py b/tests/test_eap_operations.py deleted file mode 100644 index d587b9c..0000000 --- a/tests/test_eap_operations.py +++ /dev/null @@ -1,54 +0,0 @@ -import pytest -from common.session import session -from views.eap_operations import eap_operations - -@pytest.fixture (scope='session') -def web_session(request): - web_session = session(add_provider=True) - web_session.logger.info("OPR010, OPR011, OPR012, OPR013, OPR014, OPR015: Operations on Single JBoss EAP in a server group") - - def closeSession(): - web_session.logger.info("Close browser session") - web_session.close_web_driver() - - request.addfinalizer(closeSession) - - return web_session - - -def test_eap_stop(web_session): - web_session.logger.info("Begin eap Stop Test") - assert eap_operations(web_session).stop_eap() - -def test_eap_restart(web_session): - web_session.logger.info("Begin eap Restart Test") - assert eap_operations(web_session).restart_eap() - -def test_eap_kill(web_session): - web_session.logger.info("Begin eap Kill Test") - assert eap_operations(web_session).kill_eap() - -def test_eap_start(web_session): - web_session.logger.info("Begin eap Start Test") - assert eap_operations(web_session).start_eap() - -def test_eap_suspend(web_session): - web_session.logger.info("Begin eap Suspend Test") - assert eap_operations(web_session).suspend_eap() - -def test_eap_resume(web_session): - web_session.logger.info("Begin eap Resume Test") - assert eap_operations(web_session).resume_eap() - -def test_eap_reload(web_session): - web_session.logger.info("Begin eap Reload Test") - assert eap_operations(web_session).reload_eap() - - - - - - - - - diff --git a/views/eap_operations.py b/views/eap_operations.py deleted file mode 100644 index d42819f..0000000 --- a/views/eap_operations.py +++ /dev/null @@ -1,97 +0,0 @@ -from common.ui_utils import ui_utils -from selenium.webdriver.support.ui import WebDriverWait -from selenium.webdriver.common.by import By -from time import sleep -from selenium import webdriver -from selenium.webdriver.common.keys import Keys -''' - -Created on September 22, 2016 - -@author: pyadav - -''' - -class eap_operations(): - - web_session = None - - def __init__(self, web_session): - - self.web_session = web_session - self.web_driver = web_session.web_driver - - def eap_power(self): - self.web_session.web_driver.get("{}/middleware_domain/show_list".format(self.web_session.MIQ_URL)) - assert ui_utils(self.web_session).waitForTextOnPage("Middleware Domains", 15) - self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'master')]").click() - assert ui_utils(self.web_session).waitForTextOnPage("master (Summary)", 15) - self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'Middleware Server Groups')]").click() - assert ui_utils(self.web_session).waitForTextOnPage("Server Group Name", 15) - self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'main-server-group')]").click() - assert ui_utils(self.web_session).waitForTextOnPage("main-server-group (Summary)", 15) - self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'Middleware Servers')]").click() - assert ui_utils(self.web_session).waitForTextOnPage("Server Name", 15) - self.web_session.web_driver.find_element_by_xpath("//td[contains(.,'server-one')]").click() - assert ui_utils(self.web_session).waitForTextOnPage("Properties", 15) - self.web_session.web_driver.find_element_by_xpath("//button[@title='Power']").click() - - - - def stop_eap(self): - self.eap_power() - self.web_session.web_driver.find_element_by_xpath("//a[@title='Stop this server']").click() - ui_utils(self.web_session).accept_alert(20) - assert ui_utils(self.web_session).waitForTextOnPage("Stop initiated for selected server(s)", 30) - return True - - def restart_eap(self): - self.eap_power() - self.web_session.web_driver.find_element_by_xpath("//a[@title='Restart this server']").click() - ui_utils(self.web_session).accept_alert(20) - assert ui_utils(self.web_session).waitForTextOnPage("Restart initiated for selected server(s)", 15) - return True - - def kill_eap(self): - self.eap_power() - self.web_session.web_driver.find_element_by_xpath("//a[@title='Kill this server']").click() - ui_utils(self.web_session).accept_alert(20) - assert ui_utils(self.web_session).waitForTextOnPage("Kill initiated for selected server(s)", 15) - return True - - def reload_eap(self): - self.eap_power() - self.web_session.web_driver.find_element_by_xpath("//a[contains(@id,'reload')]").click() - ui_utils(self.web_session).accept_alert(20) - assert ui_utils(self.web_session).waitForTextOnPage("Reload initiated for selected server(s)", 15) - return True - - def suspend_eap(self): - self.eap_power() - self.web_session.web_driver.find_element_by_xpath("//a[contains(@id,'suspend')]").click() - ui_utils(self.web_session).sleep(10) - self.web_session.web_driver.find_element_by_xpath("//button[@alt='Suspend']").click() - assert ui_utils(self.web_session).waitForTextOnPage("Suspend initiated for selected server(s)", 15) - return True - - def resume_eap(self): - self.eap_power() - self.web_session.web_driver.find_element_by_xpath("//a[contains(@id,'resume')]").click() - ui_utils(self.web_session).accept_alert(20) - ui_utils(self.web_session).sleep(10) - assert ui_utils(self.web_session).waitForTextOnPage("Resume initiated for selected server(s)", 15) - return True - - def start_eap(self): - self.eap_power() - self.web_session.web_driver.find_element_by_xpath("//a[contains(@title,'Start this server')]").click() - ui_utils(self.web_session).accept_alert(20) - assert ui_utils(self.web_session).waitForTextOnPage("Resume initiated for selected server(s)", 20) - return True - - - - - - -