mirror of
				https://github.com/Telecominfraproject/wlan-testing.git
				synced 2025-10-30 18:38:06 +00:00 
			
		
		
		
	Fixed Perfecto Reporting & Android Test Cases
Signed-off-by: raj-TIP <rpasupathy@perfectomobile.com>
This commit is contained in:
		| @@ -8,6 +8,7 @@ import sys | ||||
| import os | ||||
| import time | ||||
| import warnings | ||||
| from _pytest.outcomes import xfail | ||||
| import urllib3 | ||||
| from perfecto.model.model import Job, Project | ||||
| from perfecto import (PerfectoExecutionContext, PerfectoReportiumClient,TestContext, TestResultFactory) | ||||
| @@ -67,113 +68,99 @@ def getDeviceModelName(setup_perfectoMobile): | ||||
|     print("ModelName: " + deviceModel)   | ||||
|     return deviceModel | ||||
|  | ||||
| @pytest.fixture(scope="function") | ||||
| def setup_perfectoMobile_android(request): | ||||
|     from appium import webdriver | ||||
|     driver = None | ||||
|     reporting_client = None | ||||
|  | ||||
|     warnings.simplefilter("ignore", ResourceWarning) | ||||
|     urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) | ||||
|  | ||||
|     capabilities = { | ||||
|             'platformName': request.config.getini("platformName-android"), | ||||
|             'model': request.config.getini("model-android"), | ||||
|             'browserName': 'mobileOS', | ||||
|             #'automationName' : 'Appium', | ||||
|             'securityToken' : request.config.getini("securityToken"),   | ||||
|             'useAppiumForWeb' : 'false', | ||||
|             'useAppiumForHybrid' : 'false', | ||||
|             #'bundleId' : request.config.getini("appPackage-android"), | ||||
|     } | ||||
| # @pytest.fixture(scope="function") | ||||
| # def setup_perfectoMobile_android(request): | ||||
| #     from appium import webdriver | ||||
| #     driver = None | ||||
| #     reporting_client = None | ||||
|      | ||||
|     driver = webdriver.Remote('https://'+request.config.getini("perfectoURL")+'.perfectomobile.com/nexperience/perfectomobile/wd/hub', capabilities) | ||||
|     driver.implicitly_wait(35) | ||||
| #     warnings.simplefilter("ignore", ResourceWarning) | ||||
| #     urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) | ||||
|     | ||||
|     TestCaseFullName = os.environ.get('PYTEST_CURRENT_TEST').split(':')[-1].split(' ')[0] | ||||
|     nCurrentTestMethodNameSplit = re.sub(r'\[.*?\]\ *', "", TestCaseFullName) | ||||
|     try: | ||||
|         TestCaseName = nCurrentTestMethodNameSplit.removeprefix('test_') | ||||
|         print ("\nTestCaseName: " + TestCaseName) | ||||
|     except Exception as e: | ||||
|         TestCaseName = nCurrentTestMethodNameSplit | ||||
|         print("\nUpgrade Python to 3.9 to avoid test_ string in your test case name, see below URL") | ||||
|         print("https://www.andreagrandi.it/2020/10/11/python39-introduces-removeprefix-removesuffix/") | ||||
| #     capabilities = { | ||||
| #             'platformName': request.config.getini("platformName-android"), | ||||
| #             'model': request.config.getini("model-android"), | ||||
| #             'browserName': 'mobileOS', | ||||
| #             #'automationName' : 'Appium', | ||||
| #             'securityToken' : request.config.getini("securityToken"),   | ||||
| #             'useAppiumForWeb' : 'false', | ||||
| #             'useAppiumForHybrid' : 'false', | ||||
| #             #'bundleId' : request.config.getini("appPackage-android"), | ||||
| #     } | ||||
|  | ||||
|     projectname = request.config.getini("projectName") | ||||
|     projectversion = request.config.getini("projectVersion") | ||||
|     jobname = request.config.getini("jobName") | ||||
|     jobnumber = request.config.getini("jobNumber") | ||||
|     tags = request.config.getini("reportTags") | ||||
|     testCaseName = TestCaseName | ||||
| #     driver = webdriver.Remote('https://'+request.config.getini("perfectoURL")+'.perfectomobile.com/nexperience/perfectomobile/wd/hub', capabilities) | ||||
| #     driver.implicitly_wait(35) | ||||
|     | ||||
|     print("\nSetting Perfecto ReportClient....") | ||||
|     perfecto_execution_context = PerfectoExecutionContext(driver, tags, Job(jobname, jobnumber),Project(projectname, projectversion)) | ||||
|     reporting_client = PerfectoReportiumClient(perfecto_execution_context) | ||||
|     reporting_client.test_start(testCaseName, TestContext([], "Perforce")) | ||||
| #     TestCaseFullName = os.environ.get('PYTEST_CURRENT_TEST').split(':')[-1].split(' ')[0] | ||||
| #     nCurrentTestMethodNameSplit = re.sub(r'\[.*?\]\ *', "", TestCaseFullName) | ||||
| #     try: | ||||
| #         TestCaseName = nCurrentTestMethodNameSplit.removeprefix('test_') | ||||
| #         print ("\nTestCaseName: " + TestCaseName) | ||||
| #     except Exception as e: | ||||
| #         TestCaseName = nCurrentTestMethodNameSplit | ||||
| #         print("\nUpgrade Python to 3.9 to avoid test_ string in your test case name, see below URL") | ||||
| #         print("https://www.andreagrandi.it/2020/10/11/python39-introduces-removeprefix-removesuffix/") | ||||
|          | ||||
|     def teardown(): | ||||
|         reporting_client.test_stop(TestResultFactory.create_failure("See Allure Report")) | ||||
|         driver.close() | ||||
|         print("\n------------") | ||||
|         print("Driver Closed") | ||||
|         try: | ||||
|             driver.quit() | ||||
|             print("Driver Quit") | ||||
|             print("------------") | ||||
|         except Exception as e: | ||||
|             print(" -- Exception Not Able To Quit --") | ||||
|             print(e) | ||||
|         # try: | ||||
|         #     # print("\n\n---------- Tear Down ----------") | ||||
|         #     testFailed = 0 | ||||
|         #     testFailed = request.session.testsfailed | ||||
|         #     print("Testcase Failure Count: ", str(testFailed)) | ||||
|         #     if testFailed>0: | ||||
|         #         print ("Test Case Failure, please check report link: " + testCaseName) | ||||
|         #         try: | ||||
|         #             exceptionFailure = request.config.cache.get("SelectingWifiFailed", None) | ||||
|         #             reporting_client.test_stop(TestResultFactory.create_failure(exceptionFailure)) | ||||
|         #         except Exception as e: | ||||
|         #             reporting_client.test_stop(TestResultFactory.create_failure("Test Case failed -- See perfecto reports")) | ||||
|         # | ||||
|         #         seen = {None} | ||||
|         #         session = request.node | ||||
|         #         print(session) | ||||
|         #     elif testFailed<=0: | ||||
|         #         reporting_client.test_stop(TestResultFactory.create_success()) | ||||
|         # | ||||
|         #     #amount = len(request.session.items) | ||||
|         #     #print("Test Session Items: ") | ||||
|         #     #print(amount) | ||||
|         # | ||||
|         #     #tests_count = request.session.testscollected | ||||
|         #     #print("Test Collected: ") | ||||
|         #     #print(tests_count) | ||||
|         # | ||||
|         #     # print('Report-Url: ' + reporting_client.report_url()) | ||||
|         #     # print("----------------------------------------------------------") | ||||
|         #     # reporting_client.test_stop() | ||||
|         #     driver.close() | ||||
|         # except Exception as e: | ||||
|         #     print(" -- Exception While Tear Down --") | ||||
|         #     reporting_client.test_stop(TestResultFactory.create_failure(e)) | ||||
|         #     print('Report-Url-Failure: ' + reporting_client.report_url() + '\n') | ||||
|         #     driver.close() | ||||
|         #     print (e) | ||||
|         # finally: | ||||
|         #     try: | ||||
|         #         driver.quit() | ||||
|         #     except Exception as e: | ||||
|         #         print(" -- Exception Not Able To Quit --") | ||||
|         #         print (e) | ||||
| #     projectname = request.config.getini("projectName") | ||||
| #     projectversion = request.config.getini("projectVersion") | ||||
| #     jobname = request.config.getini("jobName") | ||||
| #     jobnumber = request.config.getini("jobNumber") | ||||
| #     tags = request.config.getini("reportTags") | ||||
| #     testCaseName = TestCaseName | ||||
|  | ||||
|     request.addfinalizer(teardown) | ||||
| #     print("\nSetting Perfecto ReportClient....") | ||||
| #     perfecto_execution_context = PerfectoExecutionContext(driver, tags, Job(jobname, jobnumber),Project(projectname, projectversion)) | ||||
| #     reporting_client = PerfectoReportiumClient(perfecto_execution_context) | ||||
| #     reporting_client.test_start(testCaseName, TestContext([], "Perforce")) | ||||
|  | ||||
| #     def teardown(): | ||||
| #         testFailed = 0 | ||||
| #         try: | ||||
| #             print("\n\n---------- Tear Down ----------") | ||||
|             | ||||
| #             testFailed = request.session.testsfailed | ||||
|              | ||||
| #             method_name = request.node.name | ||||
| #             print("MethodName: " + method_name) | ||||
|  | ||||
| #             #print ("TestCaseName: " + TestCaseName + "  & Status: " + str(testFailed)) | ||||
| #             #print ("TestCaseStatus: " + str(testFailed)) | ||||
|          | ||||
| #             if testFailed>0: | ||||
| #                 print ("Test Case Failure, please check report link: " + testCaseName) | ||||
| #                 #exceptionFailure = request.config.cache.get("SelectingWifiFailed", None) | ||||
| #                 reporting_client.test_stop(TestResultFactory.create_failure("Failure See Perfecto Report Execution")) | ||||
|             | ||||
| #             elif testFailed<=0: | ||||
| #                 reporting_client.test_stop(TestResultFactory.create_success()) | ||||
|           | ||||
| #             print('Report-Url: ' + reporting_client.report_url()) | ||||
| #             print("----------------------------------------------------------") | ||||
| #             driver.close() | ||||
|            | ||||
| #         except Exception as e: | ||||
| #             print(" -- Exception While Tear Down --")     | ||||
| #             reporting_client.test_stop(TestResultFactory.create_failure(e)) | ||||
| #             print('Report-Url-Failure: ' + reporting_client.report_url() + '\n') | ||||
| #             driver.close() | ||||
| #             print (e) | ||||
| #         finally: | ||||
| #             try: | ||||
| #                 testFailed = 0 | ||||
| #                 driver.quit() | ||||
| #             except Exception as e: | ||||
| #                 print(" -- Exception Not Able To Quit --")     | ||||
| #                 print (e) | ||||
|  | ||||
| #     request.addfinalizer(teardown) | ||||
|  | ||||
| #     if driver is None: | ||||
| #         yield -1 | ||||
| #     else: | ||||
| #         yield driver,reporting_client  | ||||
|  | ||||
|     if driver is None: | ||||
|         yield -1 | ||||
|     else: | ||||
|         yield driver,reporting_client  | ||||
|  | ||||
| def set_APconnMobileDevice_android(request, WifiName, WifiPass, setup_perfectoMobile, connData): | ||||
|     print("\n-------------------------------------") | ||||
| @@ -434,9 +421,11 @@ def ForgetWifiConnection(request, setup_perfectoMobile, WifiName, connData): | ||||
|             print("Verify if wifi is disconnected from: " + WifiName) | ||||
|             try: | ||||
|                 report.step_start("Verify if wifi is disconnected from: " + WifiName)  | ||||
|                 WifiForget= driver.find_element_by_xpath("//*[@resource-id='com.android.settings:id/summary' and @text='Connected']/parent::*/android.widget.TextView[@text='" + WifiName + "']")      | ||||
|                 WifiDisconnect = driver.find_element_by_xpath("//*[@resource-id='com.android.settings:id/summary' and @text='Connected']/parent::*/android.widget.TextView[@text='" + WifiName + "']")      | ||||
|                 print("Wifi Not disconnected, check xpath for: " + WifiName) | ||||
|             except NoSuchElementException and Exception: | ||||
|                 assert False | ||||
|             except Exception as e: | ||||
|                 assert True | ||||
|                 print("Wifi Disconnected Successfully: " + WifiName) | ||||
|              | ||||
|         else: | ||||
|   | ||||
| @@ -145,7 +145,8 @@ def set_APconnMobileDevice_iOS(request, WifiNameSSID, WifiPass, setup_perfectoMo | ||||
|             print("Join Button Not Enabled...Verify if Password is set properly  ") | ||||
|  | ||||
|         try: | ||||
|             WifiInternetErrMsg2 = driver.find_element_by_xpath("//*[@label='No Internet Connection']").text | ||||
|             WifiInternetErrMsg2 = WebDriverWait(driver, 30).until(EC.presence_of_element_located((MobileBy.XPATH, "//*[@label='No Internet Connection']"))) | ||||
|              #= driver.find_element_by_xpath("//*[@label='No Internet Connection']").text | ||||
|             reportFlag = False | ||||
|         except NoSuchElementException: | ||||
|             reportFlag = True | ||||
|   | ||||
| @@ -6,6 +6,7 @@ import sys | ||||
| import os | ||||
| import time | ||||
| import allure | ||||
| import re | ||||
| import logging | ||||
|  | ||||
| if "logs" not in os.listdir(): | ||||
| @@ -585,5 +586,6 @@ def setup_influx(request, testbed, get_configuration): | ||||
|     } | ||||
|     yield influx_params | ||||
|  | ||||
|  | ||||
|  | ||||
| # Need for Perforce Mobile Device Execution | ||||
| def pytest_sessionstart(session): | ||||
|     session.results = dict() | ||||
| @@ -18,7 +18,7 @@ pytestmark = [pytest.mark.sanity, pytest.mark.interop, pytest.mark.interop_and, | ||||
| if 'perfecto_libs' not in sys.path: | ||||
|     sys.path.append(f'../libs/perfecto_libs') | ||||
|  | ||||
| from android_lib import closeApp, verifyUploadDownloadSpeed_android, set_APconnMobileDevice_android, Toggle_AirplaneMode_android, ForgetWifiConnection, openApp, setup_perfectoMobile_android | ||||
| from android_lib import closeApp, verifyUploadDownloadSpeed_android, set_APconnMobileDevice_android, Toggle_AirplaneMode_android, ForgetWifiConnection, openApp | ||||
|  | ||||
| setup_params_general = { | ||||
|     "mode": "NAT", | ||||
| @@ -46,12 +46,11 @@ class TestAcessPointConnection(object): | ||||
|     @pytest.mark.fiveg | ||||
|     @pytest.mark.wpa2_personal | ||||
|     def test_AccessPointConnection_5g_WPA2_Personal(self, request, get_vif_state, get_APToMobileDevice_data, setup_perfectoMobile_android): | ||||
|          | ||||
|         profile_data = setup_params_general["ssid_modes"]["wpa2_personal"][1] | ||||
|         ssidName = profile_data["ssid_name"] | ||||
|         ssidPassword = profile_data["security_key"] | ||||
|         print ("SSID_NAME: " + ssidName) | ||||
|         print ("SSID_PASS: " + ssidPassword) | ||||
|         #print ("SSID_PASS: " + ssidPassword) | ||||
|  | ||||
|         if ssidName not in get_vif_state: | ||||
|             allure.attach(name="retest,vif state ssid not available:", body=str(get_vif_state)) | ||||
| @@ -76,12 +75,11 @@ class TestAcessPointConnection(object): | ||||
|     @pytest.mark.twog | ||||
|     @pytest.mark.wpa2_personal | ||||
|     def test_AccessPointConnection_2g_WPA2_Personal(self,request, get_vif_state, get_ToggleAirplaneMode_data, setup_perfectoMobile_android):    | ||||
|          | ||||
|         profile_data = setup_params_general["ssid_modes"]["wpa2_personal"][0]  | ||||
|         ssidName = profile_data["ssid_name"] | ||||
|         ssidPassword = profile_data["security_key"] | ||||
|         print ("SSID_NAME: " + ssidName) | ||||
|         print ("SSID_PASS: " + ssidPassword) | ||||
|         #print ("SSID_PASS: " + ssidPassword) | ||||
|  | ||||
|         if ssidName not in get_vif_state: | ||||
|             allure.attach(name="retest,vif state ssid not available:", body=str(get_vif_state)) | ||||
| @@ -106,12 +104,11 @@ class TestAcessPointConnection(object): | ||||
|     @pytest.mark.fiveg | ||||
|     @pytest.mark.wpa | ||||
|     def test_AccessPointConnection_5g_WPA(self, request, get_vif_state, get_ToggleAirplaneMode_data, setup_perfectoMobile_android):    | ||||
|          | ||||
|         profile_data = setup_params_general["ssid_modes"]["wpa"][1] | ||||
|         ssidName = profile_data["ssid_name"] | ||||
|         ssidPassword = profile_data["security_key"] | ||||
|         print ("SSID_NAME: " + ssidName) | ||||
|         print ("SSID_PASS: " + ssidPassword) | ||||
|         #print ("SSID_PASS: " + ssidPassword) | ||||
|  | ||||
|         if ssidName not in get_vif_state: | ||||
|             allure.attach(name="retest,vif state ssid not available:", body=str(get_vif_state)) | ||||
| @@ -136,12 +133,11 @@ class TestAcessPointConnection(object): | ||||
|     @pytest.mark.twog | ||||
|     @pytest.mark.wpa | ||||
|     def test_AccessPointConnection_2g_WPA(self, request, get_vif_state, get_ToggleAirplaneMode_data, setup_perfectoMobile_android): | ||||
|          | ||||
|         profile_data = setup_params_general["ssid_modes"]["wpa"][0] | ||||
|         ssidName = profile_data["ssid_name"] | ||||
|         ssidPassword = profile_data["security_key"] | ||||
|         print ("SSID_NAME: " + ssidName) | ||||
|         print ("SSID_PASS: " + ssidPassword) | ||||
|         #print ("SSID_PASS: " + ssidPassword) | ||||
|  | ||||
|         if ssidName not in get_vif_state: | ||||
|             allure.attach(name="retest,vif state ssid not available:", body=str(get_vif_state)) | ||||
|   | ||||
| @@ -18,7 +18,7 @@ if 'perfecto_libs' not in sys.path: | ||||
|  | ||||
| pytestmark = [pytest.mark.sanity, pytest.mark.interop, pytest.mark.android, pytest.mark.interop_and, pytest.mark.ToggleAirplaneMode] | ||||
|  | ||||
| from android_lib import closeApp, set_APconnMobileDevice_android, Toggle_AirplaneMode_android, ForgetWifiConnection, openApp, setup_perfectoMobile_android | ||||
| from android_lib import closeApp, set_APconnMobileDevice_android, Toggle_AirplaneMode_android, ForgetWifiConnection, openApp | ||||
|  | ||||
| setup_params_general = { | ||||
|     "mode": "NAT", | ||||
| @@ -46,12 +46,11 @@ class TestToggleAirplaneModeAndroid(object): | ||||
|     @pytest.mark.fiveg | ||||
|     @pytest.mark.wpa2_personal | ||||
|     def test_ToogleAirplaneMode_5g_WPA2_Personal(self, request, get_vif_state, get_ToggleAirplaneMode_data, setup_perfectoMobile_android): | ||||
|          | ||||
|         profile_data = setup_params_general["ssid_modes"]["wpa2_personal"][1]   | ||||
|         ssidName = profile_data["ssid_name"] | ||||
|         ssidPassword = profile_data["security_key"] | ||||
|         print ("SSID_NAME: " + ssidName) | ||||
|         print ("SSID_PASS: " + ssidPassword) | ||||
|         #print ("SSID_PASS: " + ssidPassword) | ||||
|  | ||||
|         if ssidName not in get_vif_state: | ||||
|             allure.attach(name="retest,vif state ssid not available:", body=str(get_vif_state)) | ||||
| @@ -73,12 +72,11 @@ class TestToggleAirplaneModeAndroid(object): | ||||
|     @pytest.mark.twog | ||||
|     @pytest.mark.wpa2_personal | ||||
|     def test_ToogleAirplaneMode_2g_WPA2_Personal(self, request, get_vif_state, get_ToggleAirplaneMode_data, setup_perfectoMobile_android):  | ||||
|          | ||||
|         profile_data = setup_params_general["ssid_modes"]["wpa2_personal"][0]  | ||||
|         ssidName = profile_data["ssid_name"] | ||||
|         ssidPassword = profile_data["security_key"] | ||||
|         print ("SSID_NAME: " + ssidName) | ||||
|         print ("SSID_PASS: " + ssidPassword) | ||||
|         #print ("SSID_PASS: " + ssidPassword) | ||||
|  | ||||
|         if ssidName not in get_vif_state: | ||||
|             allure.attach(name="retest,vif state ssid not available:", body=str(get_vif_state)) | ||||
| @@ -100,12 +98,11 @@ class TestToggleAirplaneModeAndroid(object): | ||||
|     @pytest.mark.fiveg | ||||
|     @pytest.mark.wpa | ||||
|     def test_ToogleAirplaneMode_5g_WPA(self, request, get_vif_state, get_ToggleAirplaneMode_data, setup_perfectoMobile_android):    | ||||
|          | ||||
|         profile_data = setup_params_general["ssid_modes"]["wpa"][1] | ||||
|         ssidName = profile_data["ssid_name"] | ||||
|         ssidPassword = profile_data["security_key"] | ||||
|         print ("SSID_NAME: " + ssidName) | ||||
|         print ("SSID_PASS: " + ssidPassword) | ||||
|         #print ("SSID_PASS: " + ssidPassword) | ||||
|  | ||||
|         if ssidName not in get_vif_state: | ||||
|             allure.attach(name="retest,vif state ssid not available:", body=str(get_vif_state)) | ||||
| @@ -127,12 +124,11 @@ class TestToggleAirplaneModeAndroid(object): | ||||
|     @pytest.mark.twog | ||||
|     @pytest.mark.wpa | ||||
|     def test_ToogleAirplaneMode_2g_WPA(self, request, get_vif_state, get_ToggleAirplaneMode_data, setup_perfectoMobile_android):   | ||||
|          | ||||
|         profile_data = setup_params_general["ssid_modes"]["wpa"][0]  | ||||
|         ssidName = profile_data["ssid_name"] | ||||
|         ssidPassword = profile_data["security_key"] | ||||
|         print ("SSID_NAME: " + ssidName) | ||||
|         print ("SSID_PASS: " + ssidPassword) | ||||
|         #print ("SSID_PASS: " + ssidPassword) | ||||
|  | ||||
|         if ssidName not in get_vif_state: | ||||
|             allure.attach(name="retest,vif state ssid not available:", body=str(get_vif_state)) | ||||
|   | ||||
| @@ -18,7 +18,7 @@ if 'perfecto_libs' not in sys.path: | ||||
|  | ||||
| pytestmark = [pytest.mark.sanity, pytest.mark.interop, pytest.mark.android, pytest.mark.interop_and, pytest.mark.openRoaming, pytest.mark.bridge] | ||||
|  | ||||
| from android_lib import closeApp, set_APconnMobileDevice_android, verify_APconnMobileDevice_Android, deleteOpenRoamingInstalledProfile, downloadInstallOpenRoamingProfile, verifyUploadDownloadSpeed_android, Toggle_AirplaneMode_android, ForgetWifiConnection, openApp, setup_perfectoMobile_android | ||||
| from android_lib import closeApp, set_APconnMobileDevice_android, verify_APconnMobileDevice_Android, deleteOpenRoamingInstalledProfile, downloadInstallOpenRoamingProfile, verifyUploadDownloadSpeed_android, Toggle_AirplaneMode_android, ForgetWifiConnection, openApp | ||||
|  | ||||
| """ | ||||
|     EAP Passpoint Test: BRIDGE Mode | ||||
| @@ -95,18 +95,13 @@ class TestOpenRoamingBridgeMode(object): | ||||
|  | ||||
|         downloadProfileSSID = setup_params_eap["ssid_modes"]["open"][0]["ssid_name"] | ||||
|         downloadProfileSSIDPass = "" | ||||
|         #profileDownloadURL = passpoint_profile_info["profile_download_url_ios"] | ||||
|         profileDownloadURL = "https://onboard.almondlabs.net/ttls/androidconfig.cfg" | ||||
|         profileName = passpoint_profile_info["profile_name_on_device"] | ||||
|         profileNameSSID = setup_params_eap["ssid_modes"]["wpa2_eap"][1]["ssid_name"] | ||||
|  | ||||
|  | ||||
|         #Delete Profile Under Settings | ||||
|         deleteOpenRoamingInstalledProfile(request, profileName, setup_perfectoMobile_android, connData)     | ||||
|  | ||||
|         #ForgetWifi | ||||
|         #ForgetWifiConnection(request, setup_perfectoMobile_android, profileNameSSID, connData) | ||||
|  | ||||
|         #Set Wifi/AP Mode | ||||
|         set_APconnMobileDevice_android(request, downloadProfileSSID, downloadProfileSSIDPass, setup_perfectoMobile_android, connData) | ||||
|  | ||||
| @@ -118,7 +113,6 @@ class TestOpenRoamingBridgeMode(object): | ||||
|  | ||||
|         try: | ||||
|             verify_APconnMobileDevice_Android(request, profileNameSSID, setup_perfectoMobile_android, connData) | ||||
|  | ||||
|              #Verify Upload download Speed from device Selection | ||||
|             verifyUploadDownloadSpeed_android(request, setup_perfectoMobile_android, connData) | ||||
|  | ||||
| @@ -172,7 +166,6 @@ class TestOpenRoamingBridgeMode(object): | ||||
|  | ||||
|         downloadProfileSSID = setup_params_eap["ssid_modes"]["open"][0]["ssid_name"] | ||||
|         downloadProfileSSIDPass = "" | ||||
|         #profileDownloadURL = passpoint_profile_info["profile_download_url_ios"] | ||||
|         profileDownloadURL = "https://onboard.almondlabs.net/ttls/androidconfig.cfg" | ||||
|         profileName = passpoint_profile_info["profile_name_on_device"] | ||||
|         profileNameSSID = setup_params_eap["ssid_modes"]["wpa2_eap"][1]["ssid_name"] | ||||
| @@ -191,7 +184,6 @@ class TestOpenRoamingBridgeMode(object): | ||||
|  | ||||
|         try: | ||||
|             verify_APconnMobileDevice_Android(request, profileName, setup_perfectoMobile_android, connData) | ||||
|  | ||||
|              #Verify Upload download Speed from device Selection | ||||
|             verifyUploadDownloadSpeed_android(request, setup_perfectoMobile_android, connData) | ||||
|  | ||||
| @@ -211,7 +203,7 @@ class TestOpenRoamingBridgeMode(object): | ||||
|         scope="function" | ||||
|     ) | ||||
|     @pytest.mark.usefixtures("push_ap_profile") | ||||
|     def test_wpa2_only_eap_2g(self, passpoint_profile_info, push_ap_profile, request, get_APToMobileDevice_data, setup_perfectoMobile_android): | ||||
|     def test_OpenRoaming_wpa2_only_eap_2g(self, passpoint_profile_info, push_ap_profile, request, get_APToMobileDevice_data, setup_perfectoMobile_android): | ||||
|         """ | ||||
|              EAP Passpoint BRIDGE Mode | ||||
|              pytest -m "interop_iOS and eap_passpoint and bridge and wpa2_only_eap and twog" | ||||
| @@ -282,7 +274,7 @@ class TestOpenRoamingBridgeMode(object): | ||||
|         scope="function" | ||||
|     ) | ||||
|     @pytest.mark.usefixtures("push_ap_profile") | ||||
|     def test_wpa2_only_eap_5g(self, passpoint_profile_info, push_ap_profile, request, get_APToMobileDevice_data, setup_perfectoMobile_android): | ||||
|     def test_OpenRoaming_wpa2_only_eap_5g(self, passpoint_profile_info, push_ap_profile, request, get_APToMobileDevice_data, setup_perfectoMobile_android): | ||||
|         """ | ||||
|              EAP Passpoint BRIDGE Mode | ||||
|              pytest -m "interop_iOS and eap_passpoint and bridge and wpa2_only_eap and fiveg" | ||||
| @@ -311,7 +303,6 @@ class TestOpenRoamingBridgeMode(object): | ||||
|  | ||||
|         downloadProfileSSID = setup_params_eap["ssid_modes"]["open"][0]["ssid_name"] | ||||
|         downloadProfileSSIDPass = "" | ||||
|         #profileDownloadURL = passpoint_profile_info["profile_download_url_ios"] | ||||
|         profileDownloadURL = "https://onboard.almondlabs.net/ttls/androidconfig.cfg" | ||||
|         profileName = passpoint_profile_info["profile_name_on_device"] | ||||
|         profileNameSSID = setup_params_eap["ssid_modes"]["wpa2_eap"][1]["ssid_name"] | ||||
| @@ -319,9 +310,6 @@ class TestOpenRoamingBridgeMode(object): | ||||
|         #Delete Profile Under Settings | ||||
|         deleteOpenRoamingInstalledProfile(request, profileName, setup_perfectoMobile_android, connData)     | ||||
|  | ||||
|         #ForgetWifi | ||||
|         #ForgetWifiConnection(request, setup_perfectoMobile_android, profileNameSSID, connData) | ||||
|  | ||||
|         #Set Wifi/AP Mode | ||||
|         set_APconnMobileDevice_android(request, downloadProfileSSID, downloadProfileSSIDPass, setup_perfectoMobile_android, connData) | ||||
|  | ||||
| @@ -333,7 +321,6 @@ class TestOpenRoamingBridgeMode(object): | ||||
|  | ||||
|         try: | ||||
|             verify_APconnMobileDevice_Android(request, profileNameSSID, setup_perfectoMobile_android, connData) | ||||
|  | ||||
|              #Verify Upload download Speed from device Selection | ||||
|             verifyUploadDownloadSpeed_android(request, setup_perfectoMobile_android, connData) | ||||
|  | ||||
|   | ||||
| @@ -18,7 +18,7 @@ if 'perfecto_libs' not in sys.path: | ||||
|  | ||||
| pytestmark = [pytest.mark.sanity, pytest.mark.interop, pytest.mark.android, pytest.mark.interop_and, pytest.mark.PassPointConnection] | ||||
|  | ||||
| from android_lib import closeApp, set_APconnMobileDevice_android, verifyUploadDownloadSpeed_android, Toggle_WifiMode_android, Toggle_AirplaneMode_android, ForgetWifiConnection, openApp, setup_perfectoMobile_android | ||||
| from android_lib import closeApp, set_APconnMobileDevice_android, verifyUploadDownloadSpeed_android, Toggle_WifiMode_android, Toggle_AirplaneMode_android, ForgetWifiConnection, openApp | ||||
|  | ||||
| setup_params_general = { | ||||
|     "mode": "NAT", | ||||
| @@ -46,12 +46,11 @@ class TestPassPointConnection(object): | ||||
|     @pytest.mark.fiveg | ||||
|     @pytest.mark.wpa2_personal | ||||
|     def test_PassPointConnection_5g_WPA2_Personal(self, request, get_vif_state, get_APToMobileDevice_data, setup_perfectoMobile_android): | ||||
|          | ||||
|         profile_data = setup_params_general["ssid_modes"]["wpa2_personal"][1]  | ||||
|         ssidName = profile_data["ssid_name"] | ||||
|         ssidPassword = profile_data["security_key"] | ||||
|         print ("SSID_NAME: " + ssidName) | ||||
|         print ("SSID_PASS: " + ssidPassword) | ||||
|         #print ("SSID_PASS: " + ssidPassword) | ||||
|  | ||||
|         if ssidName not in get_vif_state: | ||||
|             allure.attach(name="retest,vif state ssid not available:", body=str(get_vif_state)) | ||||
| @@ -76,12 +75,11 @@ class TestPassPointConnection(object): | ||||
|     @pytest.mark.twog | ||||
|     @pytest.mark.wpa2_personal | ||||
|     def test_PassPointConnection_2g_WPA2_Personal(self, request, get_vif_state, get_ToggleAirplaneMode_data, setup_perfectoMobile_android): | ||||
|          | ||||
|         profile_data = setup_params_general["ssid_modes"]["wpa2_personal"][0]  | ||||
|         ssidName = profile_data["ssid_name"] | ||||
|         ssidPassword = profile_data["security_key"] | ||||
|         print ("SSID_NAME: " + ssidName) | ||||
|         print ("SSID_PASS: " + ssidPassword) | ||||
|         #print ("SSID_PASS: " + ssidPassword) | ||||
|  | ||||
|         if ssidName not in get_vif_state: | ||||
|             allure.attach(name="retest,vif state ssid not available:", body=str(get_vif_state)) | ||||
| @@ -106,12 +104,11 @@ class TestPassPointConnection(object): | ||||
|     @pytest.mark.fiveg | ||||
|     @pytest.mark.wpa | ||||
|     def test_PassPointConnection_5g_WPA(self, request, get_vif_state, get_ToggleAirplaneMode_data, setup_perfectoMobile_android): | ||||
|          | ||||
|         profile_data = setup_params_general["ssid_modes"]["wpa"][1]  | ||||
|         ssidName = profile_data["ssid_name"] | ||||
|         ssidPassword = profile_data["security_key"] | ||||
|         print ("SSID_NAME: " + ssidName) | ||||
|         print ("SSID_PASS: " + ssidPassword) | ||||
|         #print ("SSID_PASS: " + ssidPassword) | ||||
|  | ||||
|         if ssidName not in get_vif_state: | ||||
|             allure.attach(name="retest,vif state ssid not available:", body=str(get_vif_state)) | ||||
| @@ -136,12 +133,11 @@ class TestPassPointConnection(object): | ||||
|     @pytest.mark.twog | ||||
|     @pytest.mark.wpa | ||||
|     def test_PassPointConnection_2g_WPA(self, request, get_vif_state, get_ToggleAirplaneMode_data, setup_perfectoMobile_android): | ||||
|          | ||||
|         profile_data = setup_params_general["ssid_modes"]["wpa"][0]   | ||||
|         ssidName = profile_data["ssid_name"] | ||||
|         ssidPassword = profile_data["security_key"] | ||||
|         print ("SSID_NAME: " + ssidName) | ||||
|         print ("SSID_PASS: " + ssidPassword) | ||||
|         #print ("SSID_PASS: " + ssidPassword) | ||||
|  | ||||
|         if ssidName not in get_vif_state: | ||||
|             allure.attach(name="retest,vif state ssid not available:", body=str(get_vif_state)) | ||||
|   | ||||
| @@ -18,7 +18,7 @@ if 'perfecto_libs' not in sys.path: | ||||
|  | ||||
| pytestmark = [pytest.mark.sanity, pytest.mark.interop, pytest.mark.interop_and, pytest.mark.android, pytest.mark.ToggleWifiMode] | ||||
|  | ||||
| from android_lib import closeApp, set_APconnMobileDevice_android, Toggle_WifiMode_android, Toggle_AirplaneMode_android, ForgetWifiConnection, openApp, setup_perfectoMobile_android | ||||
| from android_lib import closeApp, set_APconnMobileDevice_android, Toggle_WifiMode_android, Toggle_AirplaneMode_android, ForgetWifiConnection, openApp | ||||
|  | ||||
| setup_params_general = { | ||||
|     "mode": "NAT", | ||||
| @@ -46,12 +46,11 @@ class TestToggleWifiMode(object): | ||||
|     @pytest.mark.fiveg | ||||
|     @pytest.mark.wpa2_personal | ||||
|     def test_ToogleWifiMode_5g_WPA2_Personal(self, request, get_vif_state, get_ToggleWifiMode_data, setup_perfectoMobile_android):  | ||||
|           | ||||
|         profile_data = setup_params_general["ssid_modes"]["wpa2_personal"][1] | ||||
|         ssidName = profile_data["ssid_name"] | ||||
|         ssidPassword = profile_data["security_key"] | ||||
|         print ("SSID_NAME: " + ssidName) | ||||
|         print ("SSID_PASS: " + ssidPassword) | ||||
|         #print ("SSID_PASS: " + ssidPassword) | ||||
|  | ||||
|         if ssidName not in get_vif_state: | ||||
|             allure.attach(name="retest,vif state ssid not available:", body=str(get_vif_state)) | ||||
| @@ -73,12 +72,11 @@ class TestToggleWifiMode(object): | ||||
|     @pytest.mark.twog | ||||
|     @pytest.mark.wpa2_personal | ||||
|     def test_ToogleWifiMode_2g_WPA2_Personal(self, request, get_vif_state, get_ToggleWifiMode_data, setup_perfectoMobile_android): | ||||
|          | ||||
|         profile_data = setup_params_general["ssid_modes"]["wpa2_personal"][0]  | ||||
|         ssidName = profile_data["ssid_name"] | ||||
|         ssidPassword = profile_data["security_key"] | ||||
|         print ("SSID_NAME: " + ssidName) | ||||
|         print ("SSID_PASS: " + ssidPassword) | ||||
|         #print ("SSID_PASS: " + ssidPassword) | ||||
|  | ||||
|         if ssidName not in get_vif_state: | ||||
|             allure.attach(name="retest,vif state ssid not available:", body=str(get_vif_state)) | ||||
| @@ -100,12 +98,11 @@ class TestToggleWifiMode(object): | ||||
|     @pytest.mark.fiveg | ||||
|     @pytest.mark.wpa | ||||
|     def test_ToogleWifiMode_5g_WPA(self, request, get_vif_state, get_ToggleWifiMode_data, setup_perfectoMobile_android): | ||||
|           | ||||
|         profile_data = setup_params_general["ssid_modes"]["wpa"][1] | ||||
|         ssidName = profile_data["ssid_name"] | ||||
|         ssidPassword = profile_data["security_key"] | ||||
|         print ("SSID_NAME: " + ssidName) | ||||
|         print ("SSID_PASS: " + ssidPassword) | ||||
|         #print ("SSID_PASS: " + ssidPassword) | ||||
|  | ||||
|         if ssidName not in get_vif_state: | ||||
|             allure.attach(name="retest,vif state ssid not available:", body=str(get_vif_state)) | ||||
| @@ -127,12 +124,11 @@ class TestToggleWifiMode(object): | ||||
|     @pytest.mark.twog | ||||
|     @pytest.mark.wpa | ||||
|     def test_ToogleWifiMode_2g_WPA(self, request, get_vif_state, get_ToggleWifiMode_data, setup_perfectoMobile_android):  | ||||
|           | ||||
|         profile_data = setup_params_general["ssid_modes"]["wpa"][0] | ||||
|         ssidName = profile_data["ssid_name"] | ||||
|         ssidPassword = profile_data["security_key"] | ||||
|         print ("SSID_NAME: " + ssidName) | ||||
|         print ("SSID_PASS: " + ssidPassword) | ||||
|         #print ("SSID_PASS: " + ssidPassword) | ||||
|  | ||||
|         if ssidName not in get_vif_state: | ||||
|             allure.attach(name="retest,vif state ssid not available:", body=str(get_vif_state)) | ||||
|   | ||||
| @@ -18,7 +18,7 @@ if 'perfecto_libs' not in sys.path: | ||||
|  | ||||
| pytestmark = [pytest.mark.sanity, pytest.mark.interop, pytest.mark.android, pytest.mark.interop_and, pytest.mark.ClientConnectivity] | ||||
|  | ||||
| from android_lib import closeApp, set_APconnMobileDevice_android, verifyUploadDownloadSpeed_android, Toggle_AirplaneMode_android, ForgetWifiConnection, openApp, setup_perfectoMobile_android | ||||
| from android_lib import closeApp, set_APconnMobileDevice_android, verifyUploadDownloadSpeed_android, Toggle_AirplaneMode_android, ForgetWifiConnection, openApp | ||||
|  | ||||
| setup_params_general = { | ||||
|     "mode": "NAT", | ||||
| @@ -46,12 +46,11 @@ class TestNatMode(object): | ||||
|     @pytest.mark.fiveg | ||||
|     @pytest.mark.wpa2_personal | ||||
|     def test_ClientConnectivity_5g_WPA2_Personal(self, request, get_vif_state, get_APToMobileDevice_data, setup_perfectoMobile_android): | ||||
|          | ||||
|         profile_data = setup_params_general["ssid_modes"]["wpa2_personal"][1] | ||||
|         ssidName = profile_data["ssid_name"] | ||||
|         ssidPassword = profile_data["security_key"] | ||||
|         print ("SSID_NAME: " + ssidName) | ||||
|         print ("SSID_PASS: " + ssidPassword) | ||||
|         #print ("SSID_PASS: " + ssidPassword) | ||||
|  | ||||
|         if ssidName not in get_vif_state: | ||||
|             allure.attach(name="retest,vif state ssid not available:", body=str(get_vif_state)) | ||||
| @@ -73,12 +72,11 @@ class TestNatMode(object): | ||||
|     @pytest.mark.twog | ||||
|     @pytest.mark.wpa2_personal | ||||
|     def test_ClientConnectivity_2g_WPA2_Personal(self, request, get_vif_state, get_APToMobileDevice_data, setup_perfectoMobile_android):       | ||||
|              | ||||
|         profile_data = setup_params_general["ssid_modes"]["wpa2_personal"][0]   | ||||
|         ssidName = profile_data["ssid_name"] | ||||
|         ssidPassword = profile_data["security_key"] | ||||
|         print ("SSID_NAME: " + ssidName) | ||||
|         print ("SSID_PASS: " + ssidPassword) | ||||
|         #print ("SSID_PASS: " + ssidPassword) | ||||
|  | ||||
|         if ssidName not in get_vif_state: | ||||
|            allure.attach(name="retest,vif state ssid not available:", body=str(get_vif_state)) | ||||
| @@ -97,15 +95,15 @@ class TestNatMode(object): | ||||
|         #ForgetWifi | ||||
|         ForgetWifiConnection(request, setup_perfectoMobile_android, ssidName, connData) | ||||
|  | ||||
|  | ||||
|     @pytest.mark.twog | ||||
|     @pytest.mark.wpa | ||||
|     def test_ClientConnectivity_2g_WPA(self, request, get_vif_state, get_APToMobileDevice_data, setup_perfectoMobile_android): | ||||
|              | ||||
|         profile_data = setup_params_general["ssid_modes"]["wpa"][0]  | ||||
|         ssidName = profile_data["ssid_name"] | ||||
|         ssidPassword = profile_data["security_key"] | ||||
|         print ("SSID_NAME: " + ssidName) | ||||
|         print ("SSID_PASS: " + ssidPassword) | ||||
|         #print ("SSID_PASS: " + ssidPassword) | ||||
|  | ||||
|         if ssidName not in get_vif_state: | ||||
|             allure.attach(name="retest,vif state ssid not available:", body=str(get_vif_state)) | ||||
| @@ -124,15 +122,15 @@ class TestNatMode(object): | ||||
|         #ForgetWifi | ||||
|         ForgetWifiConnection(request, setup_perfectoMobile_android, ssidName, connData) | ||||
|          | ||||
|  | ||||
|     @pytest.mark.fiveg | ||||
|     @pytest.mark.wpa | ||||
|     def test_ClientConnectivity_5g_WPA(self, request, get_vif_state, get_APToMobileDevice_data, setup_perfectoMobile_android): | ||||
|              | ||||
|         profile_data = setup_params_general["ssid_modes"]["wpa"][1] | ||||
|         ssidName = profile_data["ssid_name"] | ||||
|         ssidPassword = profile_data["security_key"] | ||||
|         print ("SSID_NAME: " + ssidName) | ||||
|         print ("SSID_PASS: " + ssidPassword) | ||||
|         #print ("SSID_PASS: " + ssidPassword) | ||||
|  | ||||
|         if ssidName not in get_vif_state: | ||||
|             allure.attach(name="retest,vif state ssid not available:", body=str(get_vif_state)) | ||||
| @@ -150,3 +148,4 @@ class TestNatMode(object): | ||||
|  | ||||
|         #ForgetWifi | ||||
|         ForgetWifiConnection(request, setup_perfectoMobile_android, ssidName, connData) | ||||
|  | ||||
|   | ||||
| @@ -39,167 +39,11 @@ from configuration import CONFIGURATION | ||||
|  | ||||
| from urllib3 import exceptions | ||||
|  | ||||
| @pytest.fixture(scope="class") | ||||
| def setup_perfectoMobileWeb(request): | ||||
|     from selenium import webdriver | ||||
|     rdriver = None | ||||
|     reporting_client = None | ||||
|      | ||||
|     warnings.simplefilter("ignore", ResourceWarning) | ||||
|     urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) | ||||
|  | ||||
|     capabilities = { | ||||
|             'platformName': request.config.getini("platformName-iOS"), | ||||
|             'model': request.config.getini("model-iOS"), | ||||
|             'browserName': request.config.getini("browserType-iOS"), | ||||
|             'securityToken' : request.config.getini("securityToken"), | ||||
|     } | ||||
|  | ||||
|     rdriver = webdriver.Remote('https://'+request.config.getini("perfectoURL")+'.perfectomobile.com/nexperience/perfectomobile/wd/hub', capabilities) | ||||
|     rdriver.implicitly_wait(35) | ||||
|  | ||||
|     projectname = request.config.getini("projectName") | ||||
|     projectversion = request.config.getini("projectVersion") | ||||
|     jobname = request.config.getini("jobName") | ||||
|     jobnumber = request.config.getini("jobNumber") | ||||
|     tags = request.config.getini("reportTags") | ||||
|     testCaseName = request.config.getini("jobName") | ||||
|  | ||||
|     print("Setting Perfecto ReportClient....") | ||||
|     perfecto_execution_context = PerfectoExecutionContext(rdriver, tags, Job(jobname, jobnumber),Project(projectname, projectversion)) | ||||
|     reporting_client = PerfectoReportiumClient(perfecto_execution_context) | ||||
|     reporting_client.test_start(testCaseName, TestContext([], "Perforce")) | ||||
|  | ||||
|     def teardown(): | ||||
|         try: | ||||
|             print(" -- Tear Down --")      | ||||
|             reporting_client.test_stop(TestResultFactory.create_success()) | ||||
|             print('Report-Url: ' + reporting_client.report_url() + '\n') | ||||
|             rdriver.close() | ||||
|         except Exception as e: | ||||
|             print(" -- Exception Not Able To close --")     | ||||
|             print (e.message) | ||||
|         finally: | ||||
|             try: | ||||
|                 rdriver.quit() | ||||
|             except Exception as e: | ||||
|                 print(" -- Exception Not Able To Quit --")     | ||||
|                 print (e.message) | ||||
|  | ||||
|     request.addfinalizer(teardown) | ||||
|  | ||||
|     if rdriver is None: | ||||
|         yield -1 | ||||
|     else: | ||||
|         yield rdriver,reporting_client  | ||||
|  | ||||
|  | ||||
| @pytest.fixture(scope="function") | ||||
| def setup_perfectoMobile_iOS(request): | ||||
|     from appium import webdriver | ||||
|     driver = None | ||||
|     reporting_client = None | ||||
|      | ||||
|     warnings.simplefilter("ignore", ResourceWarning) | ||||
|     urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) | ||||
|     | ||||
|     capabilities = { | ||||
|             'platformName': request.config.getini("platformName-iOS"), | ||||
|             'model': request.config.getini("model-iOS"), | ||||
|             'browserName': 'safari', | ||||
|             #'automationName' : 'Appium', | ||||
|             'securityToken' : request.config.getini("securityToken"),   | ||||
|             'useAppiumForWeb' : 'false',  | ||||
|             'autoAcceptAlerts' : 'true', | ||||
|             #'bundleId' : request.config.getini("bundleId-iOS"), | ||||
|             'useAppiumForHybrid' : 'false', | ||||
|     } | ||||
|  | ||||
|     driver = webdriver.Remote('https://'+request.config.getini("perfectoURL")+'.perfectomobile.com/nexperience/perfectomobile/wd/hub', capabilities) | ||||
|     driver.implicitly_wait(35) | ||||
|     | ||||
|     TestCaseFullName = os.environ.get('PYTEST_CURRENT_TEST').split(':')[-1].split(' ')[0] | ||||
|     nCurrentTestMethodNameSplit = re.sub(r'\[.*?\]\ *', "", TestCaseFullName) | ||||
|     try: | ||||
|         TestCaseName = nCurrentTestMethodNameSplit.removeprefix('test_') | ||||
|         print ("\nTestCaseName: " + TestCaseName) | ||||
|     except Exception as e: | ||||
|         TestCaseName = nCurrentTestMethodNameSplit | ||||
|         print("\nUpgrade Python to 3.9 to avoid test_ string in your test case name, see below URL") | ||||
|         print("https://www.andreagrandi.it/2020/10/11/python39-introduces-removeprefix-removesuffix/") | ||||
|          | ||||
|     projectname = request.config.getini("projectName") | ||||
|     projectversion = request.config.getini("projectVersion") | ||||
|     jobname = request.config.getini("jobName") | ||||
|     jobnumber = request.config.getini("jobNumber") | ||||
|     tags = request.config.getini("reportTags") | ||||
|     testCaseName = TestCaseName | ||||
|  | ||||
|     print("\nSetting Perfecto ReportClient....") | ||||
|     perfecto_execution_context = PerfectoExecutionContext(driver, tags, Job(jobname, jobnumber),Project(projectname, projectversion)) | ||||
|     reporting_client = PerfectoReportiumClient(perfecto_execution_context) | ||||
|     reporting_client.test_start(testCaseName, TestContext([], "Perforce")) | ||||
|  | ||||
|     def teardown(): | ||||
|         reporting_client.test_stop(TestResultFactory.create_failure("See Allure Report")) | ||||
|         driver.close() | ||||
|         print("\n------------") | ||||
|         print("Driver Closed") | ||||
|         try: | ||||
|             driver.quit() | ||||
|             print("Driver Quit") | ||||
|             print("------------") | ||||
|         except Exception as e: | ||||
|             print(" -- Exception Not Able To Quit --") | ||||
|             print(e) | ||||
|  | ||||
|         # try: | ||||
|         #     print("\n\n---------- Tear Down ----------") | ||||
|         # | ||||
|         #     testFailed = request.session.testsfailed | ||||
|         #     if testFailed>0: | ||||
|         #         print ("Test Case Failure, please check report link: " + testCaseName) | ||||
|         #         reporting_client.test_stop(TestResultFactory.create_failure(request.config.cache.get("SelectingWifiFailed", None))) | ||||
|         #         request.config.cache.set(key="SelectingWifiFailed", value="Cache Cleared!!") | ||||
|         #         #seen = {None} | ||||
|         #         #session = request.node | ||||
|         #         #print(session) | ||||
|         #     elif testFailed<=0: | ||||
|         #         reporting_client.test_stop(TestResultFactory.create_success()) | ||||
|         # | ||||
|         #     #amount = len(request.session.items) | ||||
|         #     #print("Test Session Items: ") | ||||
|         #     #print(amount) | ||||
|         # | ||||
|         #     #tests_count = request.session.testscollected | ||||
|         #     #print("Test Collected: ") | ||||
|         #     #print(tests_count) | ||||
|         # | ||||
|         #     print('Report-Url: ' + reporting_client.report_url()) | ||||
|         #     print("----------------------------------------------------------") | ||||
|         #     driver.close() | ||||
|         # except Exception as e: | ||||
|         #     print(" -- Exception While Tear Down --") | ||||
|         #     reporting_client.test_stop(TestResultFactory.create_failure("Exception")) | ||||
|         #     print('Report-Url-Failure: ' + reporting_client.report_url() + '\n') | ||||
|         # | ||||
|         #     driver.close() | ||||
|         # | ||||
|         #     print (e) | ||||
|         # finally: | ||||
|         #     try: | ||||
|         #         driver.quit() | ||||
|         #     except Exception as e: | ||||
|         #         print(" -- Exception Not Able To Quit --") | ||||
|         #         print (e) | ||||
|      | ||||
|  | ||||
|     request.addfinalizer(teardown) | ||||
|  | ||||
|     if driver is None: | ||||
|         yield -1 | ||||
|     else: | ||||
|         yield driver,reporting_client  | ||||
| reporting_client = None | ||||
| testCaseNameList = [] | ||||
| testCaseStatusList = [] | ||||
| testCaseErrorMsg = [] | ||||
| testCaseReportURL = [] | ||||
|  | ||||
|  | ||||
| @pytest.fixture(scope="function") | ||||
| @@ -775,3 +619,296 @@ def get_vif_state(get_apnos, get_configuration): | ||||
|     vif_state.sort() | ||||
|     allure.attach(name="vif_state", body=str(vif_state)) | ||||
|     yield vif_state | ||||
|  | ||||
|  | ||||
|  | ||||
| @pytest.hookimpl(tryfirst=True, hookwrapper=True) | ||||
| def pytest_runtest_makereport(item, call): | ||||
|     outcome = yield | ||||
|     result = outcome.get_result() | ||||
|     #testCaseStatusValue = "" | ||||
|     testCasePassedStatusValue = "" | ||||
|     testCaseFailedStatusValue = "" | ||||
|     testCaseNameList = [] | ||||
|     testCaseStatusList = [] | ||||
|     testCaseErrorMsg = [] | ||||
|     testCaseReportURL = [] | ||||
|  | ||||
|     if result.when == 'call': | ||||
|         item.session.results[item] = result | ||||
|  | ||||
|         #Gets the Current Test Case Name | ||||
|         TestCaseFullName = os.environ.get('PYTEST_CURRENT_TEST').split(':')[-1].split(' ')[0] | ||||
|         nCurrentTestMethodNameSplit = re.sub(r'\[.*?\]\ *', "", TestCaseFullName) | ||||
|         #print("TestCasefullNameTEST: " + TestCaseFullName) | ||||
|         try:       | ||||
|             #TestCaseName = nCurrentTestMethodNameSplit.removeprefix('test_') | ||||
|             TestCaseName = nCurrentTestMethodNameSplit.replace('test_', '') | ||||
|             #print ("\nTestCaseName: " + TestCaseName) | ||||
|         except Exception as e: | ||||
|             TestCaseName = nCurrentTestMethodNameSplit | ||||
|             print("\nUpgrade Python to 3.9 to avoid test_ string in your test case name, see below URL") | ||||
|             #print("https://www.andreagrandi.it/2020/10/11/python39-introduces-removeprefix-removesuffix/") | ||||
|  | ||||
|         if result.outcome == "failed": | ||||
|             testCaseFailedStatusValue = "FAILED" | ||||
|             exception = call.excinfo.value | ||||
|             exception_class = call.excinfo.type | ||||
|             exception_class_name = call.excinfo.typename | ||||
|             exception_type_and_message_formatted = call.excinfo.exconly() | ||||
|             exception_traceback = call.excinfo.traceback | ||||
|  | ||||
|             reporting_client.test_stop(TestResultFactory.create_failure(str(testCaseErrorMsg))) | ||||
|             testCaseNameList.append(TestCaseName) | ||||
|             testCaseStatusList.append(testCaseFailedStatusValue) | ||||
|             testCaseErrorMsg.append(exception_type_and_message_formatted) | ||||
|             testCaseReportURL.append(reporting_client.report_url())            | ||||
|  | ||||
|             print("\n     TestStatus: " + testCaseFailedStatusValue) | ||||
|             print("     FailureMsg: " + str(testCaseErrorMsg)) | ||||
|             reportPerfecto(TestCaseName, testCaseFailedStatusValue, testCaseErrorMsg, str(reporting_client.report_url())) | ||||
|  | ||||
|         if result.outcome == "passed": | ||||
|             testCasePassedStatusValue = "PASSED" | ||||
|             reporting_client.test_stop(TestResultFactory.create_success()) | ||||
|             testCaseNameList.append(TestCaseName) | ||||
|             testCaseStatusList.append(testCasePassedStatusValue) | ||||
|             testCaseReportURL.append(reporting_client.report_url()) | ||||
|             print("\n     TestStatus:  " + testCasePassedStatusValue) | ||||
|             reportPerfecto(TestCaseName, testCasePassedStatusValue, "N/A", str(reporting_client.report_url())) | ||||
|  | ||||
| def pytest_sessionfinish(session, exitstatus): | ||||
|  | ||||
|     print() | ||||
|     #print('Perfecto TestCase Execution Status:', exitstatus) | ||||
|     passed_amount = sum(1 for result in session.results.values() if result.passed) | ||||
|     failed_amount = sum(1 for result in session.results.values() if result.failed) | ||||
|     #  print(f'There are {passed_amount} passed and {failed_amount} failed tests')         | ||||
|     TotalExecutedCount = failed_amount + passed_amount | ||||
|  | ||||
|     print('\n------------------------------------') | ||||
|     print('Perfecto TestCase Execution Summary')   | ||||
|     print('------------------------------------') | ||||
|     print('Total TestCase Executed: ' + str(TotalExecutedCount))   | ||||
|     print('Total Passed: ' + str(passed_amount)) | ||||
|     print('Total Failed: ' + str(failed_amount) + "\n") | ||||
|    | ||||
|     for index in range(len(testCaseNameList)): | ||||
|         print(str(index+1) + ") " + str(testCaseNameList[index]) + " : " + str(testCaseStatusList[index])) | ||||
|         print("     ReportURL: " + str(testCaseReportURL[index])) | ||||
|         print("     FailureMsg: " + str(testCaseErrorMsg[index]) + "\n") | ||||
|          | ||||
|     print('------------------------------------------------------------------\n\n\n\n') | ||||
|  | ||||
| @pytest.fixture(scope="function") | ||||
| def setup_perfectoMobile_android(request): | ||||
|     from appium import webdriver | ||||
|     driver = None | ||||
|     reporting_client = None | ||||
|      | ||||
|     warnings.simplefilter("ignore", ResourceWarning) | ||||
|     urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) | ||||
|     | ||||
|     capabilities = { | ||||
|             'platformName': request.config.getini("platformName-android"), | ||||
|             'model': request.config.getini("model-android"), | ||||
|             'browserName': 'mobileOS', | ||||
|             #'automationName' : 'Appium', | ||||
|             'securityToken' : request.config.getini("securityToken"),   | ||||
|             'useAppiumForWeb' : 'false', | ||||
|             'useAppiumForHybrid' : 'false', | ||||
|             #'bundleId' : request.config.getini("appPackage-android"), | ||||
|     } | ||||
|  | ||||
|     driver = webdriver.Remote('https://'+request.config.getini("perfectoURL")+'.perfectomobile.com/nexperience/perfectomobile/wd/hub', capabilities) | ||||
|     driver.implicitly_wait(35) | ||||
|     | ||||
|     TestCaseFullName = os.environ.get('PYTEST_CURRENT_TEST').split(':')[-1].split(' ')[0] | ||||
|     nCurrentTestMethodNameSplit = re.sub(r'\[.*?\]\ *', "", TestCaseFullName) | ||||
|     try: | ||||
|         #TestCaseName = nCurrentTestMethodNameSplit.removeprefix('test_') | ||||
|         TestCaseName = nCurrentTestMethodNameSplit.replace('test_', '') | ||||
|         print ("\n\nExecuting TestCase: " + TestCaseName) | ||||
|     except Exception as e: | ||||
|         TestCaseName = nCurrentTestMethodNameSplit | ||||
|         print("\nUpgrade Python to 3.9 to avoid test_ string in your test case name, see below URL") | ||||
|         #print("https://www.andreagrandi.it/2020/10/11/python39-introduces-removeprefix-removesuffix/") | ||||
|          | ||||
|     projectname = request.config.getini("projectName") | ||||
|     projectversion = request.config.getini("projectVersion") | ||||
|     jobname = request.config.getini("jobName") | ||||
|     jobnumber = request.config.getini("jobNumber") | ||||
|     tags = request.config.getini("reportTags") | ||||
|     testCaseName = TestCaseName | ||||
|  | ||||
|     #print("\nSetting Perfecto ReportClient....") | ||||
|     perfecto_execution_context = PerfectoExecutionContext(driver, tags, Job(jobname, jobnumber),Project(projectname, projectversion)) | ||||
|     reporting_client = PerfectoReportiumClient(perfecto_execution_context) | ||||
|     reporting_client.test_start(testCaseName, TestContext([], "Perforce")) | ||||
|     reportClient(reporting_client) | ||||
|  | ||||
|     def teardown(): | ||||
|         try: | ||||
|             print("\n---------- Tear Down ----------") | ||||
|             print('Report-Url: ' + reporting_client.report_url()) | ||||
|             print("----------------------------------------------------------\n\n\n\n") | ||||
|             driver.close() | ||||
|         except Exception as e: | ||||
|             print(" -- Exception While Tear Down --")     | ||||
|             driver.close() | ||||
|             print (e) | ||||
|         finally: | ||||
|             try: | ||||
|                 driver.quit() | ||||
|             except Exception as e: | ||||
|                 print(" -- Exception Not Able To Quit --")     | ||||
|                 print (e) | ||||
|  | ||||
|     request.addfinalizer(teardown) | ||||
|  | ||||
|     if driver is None: | ||||
|         yield -1 | ||||
|     else: | ||||
|         yield driver,reporting_client  | ||||
|  | ||||
| def reportClient(value): | ||||
|     global reporting_client   # declare a to be a global | ||||
|     reporting_client = value  # this sets the global value of a | ||||
|  | ||||
| def reportPerfecto(testCaseName, testCaseStatus, testErrorMsg, reportURL): | ||||
|     global testCaseNameList   # declare a to be a global | ||||
|     global testCaseStatusList | ||||
|     global testCaseErrorMsg | ||||
|     global testCaseReportURL | ||||
|  | ||||
|     testCaseNameList.append(testCaseName) | ||||
|     testCaseStatusList.append(testCaseStatus) | ||||
|     testCaseErrorMsg.append(str(testErrorMsg)) | ||||
|     testCaseReportURL.append(reportURL) | ||||
|  | ||||
| @pytest.fixture(scope="class") | ||||
| def setup_perfectoMobileWeb(request): | ||||
|     from selenium import webdriver | ||||
|     rdriver = None | ||||
|     reporting_client = None | ||||
|      | ||||
|     warnings.simplefilter("ignore", ResourceWarning) | ||||
|     urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) | ||||
|  | ||||
|     capabilities = { | ||||
|             'platformName': request.config.getini("platformName-iOS"), | ||||
|             'model': request.config.getini("model-iOS"), | ||||
|             'browserName': request.config.getini("browserType-iOS"), | ||||
|             'securityToken' : request.config.getini("securityToken"), | ||||
|     } | ||||
|  | ||||
|     rdriver = webdriver.Remote('https://'+request.config.getini("perfectoURL")+'.perfectomobile.com/nexperience/perfectomobile/wd/hub', capabilities) | ||||
|     rdriver.implicitly_wait(35) | ||||
|  | ||||
|     projectname = request.config.getini("projectName") | ||||
|     projectversion = request.config.getini("projectVersion") | ||||
|     jobname = request.config.getini("jobName") | ||||
|     jobnumber = request.config.getini("jobNumber") | ||||
|     tags = request.config.getini("reportTags") | ||||
|     testCaseName = request.config.getini("jobName") | ||||
|  | ||||
|     print("Setting Perfecto ReportClient....") | ||||
|     perfecto_execution_context = PerfectoExecutionContext(rdriver, tags, Job(jobname, jobnumber),Project(projectname, projectversion)) | ||||
|     reporting_client = PerfectoReportiumClient(perfecto_execution_context) | ||||
|     reporting_client.test_start(testCaseName, TestContext([], "Perforce")) | ||||
|  | ||||
|     def teardown(): | ||||
|         try: | ||||
|             print(" -- Tear Down --")      | ||||
|             reporting_client.test_stop(TestResultFactory.create_success()) | ||||
|             print('Report-Url: ' + reporting_client.report_url() + '\n') | ||||
|             rdriver.close() | ||||
|         except Exception as e: | ||||
|             print(" -- Exception Not Able To close --")     | ||||
|             print (e.message) | ||||
|         finally: | ||||
|             try: | ||||
|                 rdriver.quit() | ||||
|             except Exception as e: | ||||
|                 print(" -- Exception Not Able To Quit --")     | ||||
|                 print (e.message) | ||||
|  | ||||
|     request.addfinalizer(teardown) | ||||
|  | ||||
|     if rdriver is None: | ||||
|         yield -1 | ||||
|     else: | ||||
|         yield rdriver,reporting_client  | ||||
|  | ||||
| @pytest.fixture(scope="function") | ||||
| def setup_perfectoMobile_iOS(request): | ||||
|     from appium import webdriver | ||||
|     driver = None | ||||
|     reporting_client = None | ||||
|      | ||||
|     warnings.simplefilter("ignore", ResourceWarning) | ||||
|     urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) | ||||
|     | ||||
|     capabilities = { | ||||
|             'platformName': request.config.getini("platformName-iOS"), | ||||
|             'model': request.config.getini("model-iOS"), | ||||
|             'browserName': 'safari', | ||||
|             #'automationName' : 'Appium', | ||||
|             'securityToken' : request.config.getini("securityToken"),   | ||||
|             'useAppiumForWeb' : 'false',  | ||||
|             'autoAcceptAlerts' : 'true', | ||||
|             #'bundleId' : request.config.getini("bundleId-iOS"), | ||||
|             'useAppiumForHybrid' : 'false', | ||||
|     } | ||||
|  | ||||
|     driver = webdriver.Remote('https://'+request.config.getini("perfectoURL")+'.perfectomobile.com/nexperience/perfectomobile/wd/hub', capabilities) | ||||
|     driver.implicitly_wait(35) | ||||
|     | ||||
|     TestCaseFullName = os.environ.get('PYTEST_CURRENT_TEST').split(':')[-1].split(' ')[0] | ||||
|     nCurrentTestMethodNameSplit = re.sub(r'\[.*?\]\ *', "", TestCaseFullName) | ||||
|     try: | ||||
|         #TestCaseName = nCurrentTestMethodNameSplit.removeprefix('test_') | ||||
|         TestCaseName = nCurrentTestMethodNameSplit.replace('test_', '') | ||||
|         print ("\n\nExecuting TestCase: " + TestCaseName) | ||||
|     except Exception as e: | ||||
|         TestCaseName = nCurrentTestMethodNameSplit | ||||
|         print("\nUpgrade Python to 3.9 to avoid test_ string in your test case name, see below URL") | ||||
|         #print("https://www.andreagrandi.it/2020/10/11/python39-introduces-removeprefix-removesuffix/") | ||||
|          | ||||
|     projectname = request.config.getini("projectName") | ||||
|     projectversion = request.config.getini("projectVersion") | ||||
|     jobname = request.config.getini("jobName") | ||||
|     jobnumber = request.config.getini("jobNumber") | ||||
|     tags = request.config.getini("reportTags") | ||||
|     testCaseName = TestCaseName | ||||
|  | ||||
|     print("\nSetting Perfecto ReportClient....") | ||||
|     perfecto_execution_context = PerfectoExecutionContext(driver, tags, Job(jobname, jobnumber),Project(projectname, projectversion)) | ||||
|     reporting_client = PerfectoReportiumClient(perfecto_execution_context) | ||||
|     reporting_client.test_start(testCaseName, TestContext([], "Perforce")) | ||||
|     reportClient(reporting_client) | ||||
|  | ||||
|     def teardown(): | ||||
|         try: | ||||
|             print("\n---------- Tear Down ----------") | ||||
|             print('Report-Url: ' + reporting_client.report_url()) | ||||
|             print("----------------------------------------------------------\n\n\n\n") | ||||
|             driver.close() | ||||
|         except Exception as e: | ||||
|             print(" -- Exception While Tear Down --")     | ||||
|             driver.close() | ||||
|             print (e) | ||||
|         finally: | ||||
|             try: | ||||
|                 driver.quit() | ||||
|             except Exception as e: | ||||
|                 print(" -- Exception Not Able To Quit --")     | ||||
|                 print (e) | ||||
|      | ||||
|     request.addfinalizer(teardown) | ||||
|  | ||||
|     if driver is None: | ||||
|         yield -1 | ||||
|     else: | ||||
|         yield driver,reporting_client  | ||||
|  | ||||
|   | ||||
| @@ -19,7 +19,7 @@ if 'perfecto_libs' not in sys.path: | ||||
|  | ||||
| from iOS_lib import closeApp, openApp, get_WifiIPAddress_iOS, ForgetWifiConnection, ping_deftapps_iOS, Toggle_AirplaneMode_iOS, set_APconnMobileDevice_iOS, verify_APconnMobileDevice_iOS, Toggle_WifiMode_iOS, tearDown | ||||
|  | ||||
| pytestmark = [pytest.mark.sanity, pytest.mark.interop, pytest.mark.ios, pytest.mark.interop_ios, pytest.mark.AccessPassPointConnectivety] | ||||
| pytestmark = [pytest.mark.sanity, pytest.mark.interop, pytest.mark.ios, pytest.mark.interop_ios, pytest.mark.AccessPointConnection] | ||||
|  | ||||
| setup_params_general = { | ||||
|     "mode": "NAT", | ||||
| @@ -47,13 +47,11 @@ class TestAccessPointConnectivety(object): | ||||
|     @pytest.mark.fiveg | ||||
|     @pytest.mark.wpa2_personal | ||||
|     def test_AccessPointConnection_5g_WPA2_Personal(self, request, get_AccessPointConn_data, setup_perfectoMobile_iOS):     | ||||
|          | ||||
|         profile_data = setup_params_general["ssid_modes"]["wpa2_personal"][1] | ||||
|         ssidName = profile_data["ssid_name"] | ||||
|         ssidPassword = profile_data["security_key"] | ||||
|  | ||||
|         print ("SSID_NAME: " + ssidName) | ||||
|         print ("SSID_PASS: " + ssidPassword) | ||||
|         #print ("SSID_PASS: " + ssidPassword) | ||||
|  | ||||
|         report = setup_perfectoMobile_iOS[1] | ||||
|         driver = setup_perfectoMobile_iOS[0] | ||||
| @@ -76,12 +74,11 @@ class TestAccessPointConnectivety(object): | ||||
|     @pytest.mark.twog | ||||
|     @pytest.mark.wpa2_personal | ||||
|     def test_AccessPointConnection_2g_WPA2_Personal(self, request, get_AccessPointConn_data, setup_perfectoMobile_iOS): | ||||
|          | ||||
|         profile_data = setup_params_general["ssid_modes"]["wpa2_personal"][0]   | ||||
|         ssidName = profile_data["ssid_name"] | ||||
|         ssidPassword = profile_data["security_key"] | ||||
|         print ("SSID_NAME: " + ssidName) | ||||
|         print ("SSID_PASS: " + ssidPassword) | ||||
|         #print ("SSID_PASS: " + ssidPassword) | ||||
|       | ||||
|         report = setup_perfectoMobile_iOS[1] | ||||
|         driver = setup_perfectoMobile_iOS[0] | ||||
| @@ -104,13 +101,11 @@ class TestAccessPointConnectivety(object): | ||||
|     @pytest.mark.fiveg | ||||
|     @pytest.mark.wpa | ||||
|     def test_AccessPointConnection_5g_WPA(self, request, get_AccessPointConn_data, setup_perfectoMobile_iOS): | ||||
|          | ||||
|         profile_data = setup_params_general["ssid_modes"]["wpa"][1] | ||||
|         ssidName = profile_data["ssid_name"] | ||||
|         ssidPassword = profile_data["security_key"] | ||||
|         print ("SSID_NAME: " + ssidName) | ||||
|         print ("SSID_PASS: " + ssidPassword) | ||||
|       | ||||
|         #print ("SSID_PASS: " + ssidPassword) | ||||
|         report = setup_perfectoMobile_iOS[1] | ||||
|         driver = setup_perfectoMobile_iOS[0] | ||||
|         connData = get_AccessPointConn_data | ||||
| @@ -132,12 +127,11 @@ class TestAccessPointConnectivety(object): | ||||
|     @pytest.mark.twog | ||||
|     @pytest.mark.wpa | ||||
|     def test_AccessPointConnection_2g_WPA(self, request, get_AccessPointConn_data, setup_perfectoMobile_iOS): | ||||
|          | ||||
|         profile_data = setup_params_general["ssid_modes"]["wpa"][0]  | ||||
|         ssidName = profile_data["ssid_name"] | ||||
|         ssidPassword = profile_data["security_key"] | ||||
|         print ("SSID_NAME: " + ssidName) | ||||
|         print ("SSID_PASS: " + ssidPassword) | ||||
|         #print ("SSID_PASS: " + ssidPassword) | ||||
|  | ||||
|         report = setup_perfectoMobile_iOS[1] | ||||
|         driver = setup_perfectoMobile_iOS[0] | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 raj-TIP
					raj-TIP