From b4910948ac32f63ec0b9278f783a8312969364c1 Mon Sep 17 00:00:00 2001 From: sushant Date: Thu, 21 Oct 2021 01:25:48 +0530 Subject: [PATCH 1/6] - e2e for expresswifi Signed-off-by: Sushant Bawiskar --- libs/controller/controller_2x/controller.py | 17 +- libs/perfecto_libs/android_lib.py | 63 ++ libs/perfecto_libs/iOS_lib.py | 674 ++++++++++++-------- tests/fixtures_2x.py | 7 +- 4 files changed, 476 insertions(+), 285 deletions(-) diff --git a/libs/controller/controller_2x/controller.py b/libs/controller/controller_2x/controller.py index 2da52bf4d..2aef4a756 100644 --- a/libs/controller/controller_2x/controller.py +++ b/libs/controller/controller_2x/controller.py @@ -13,6 +13,7 @@ import allure import requests from operator import itemgetter from pathlib import Path +from configuration import EXPRESS_WIFI from requests.adapters import HTTPAdapter import logging @@ -219,7 +220,7 @@ class FMSUtils: body=str(response.status_code) + "\n" + str(response.json()) + "\n" ) - + print(response) def ap_model_lookup(self, model=""): @@ -284,7 +285,7 @@ class FMSUtils: return "error" - + class UProfileUtility: @@ -385,6 +386,18 @@ class UProfileUtility: } self.mode = None + def set_express_wifi(self): + if self.mode == "NAT": + self.base_profile_config["interfaces"][0]["services"] = ["lldp", "ssh"] + self.base_profile_config["interfaces"][1]["services"] = ["ssh", "lldp", "open-flow"] + self.base_profile_config["interfaces"][1]["ipv4"]["subnet"] = "192.168.97.1/24" + self.base_profile_config["interfaces"][1]["ipv4"]["dhcp"]["lease-count"] = 100 + self.base_profile_config['services'] = EXPRESS_WIFI["services"] + self.base_profile_config['metrics']['wifi-frames'] = EXPRESS_WIFI["wifi_frames"] + self.base_profile_config['metrics']['dhcp-snooping'] = EXPRESS_WIFI["dhcp_snooping"] + + + def encryption_lookup(self, encryption="psk"): encryption_mapping = { "none": "open", diff --git a/libs/perfecto_libs/android_lib.py b/libs/perfecto_libs/android_lib.py index a887311d8..f1573a982 100644 --- a/libs/perfecto_libs/android_lib.py +++ b/libs/perfecto_libs/android_lib.py @@ -114,6 +114,8 @@ def set_APconnMobileDevice_android(request, WifiName, WifiPass, setup_perfectoMo except NoSuchElementException: print("Exception: Verify Xpath - Update/check Xpath for Click Connections") + + try: print("Get Connected Wifi Name if any") report.step_start("Get Connected Wifi Name if any") @@ -143,6 +145,7 @@ def set_APconnMobileDevice_android(request, WifiName, WifiPass, setup_perfectoMo report.step_start("Clicking Wi-Fi") wifiElement = driver.find_element_by_xpath("//*[@text='Wi-Fi']") wifiElement.click() + Wifi_AP_Name="" if Wifi_AP_Name.__eq__(WifiName): print("Wifi Name Matches - Already Connected To: " + Wifi_AP_Name) @@ -2682,3 +2685,63 @@ def wifi_connect_eap(request, WifiName, User, ttls_passwd, setup_perfectoMobile, def close_driver(driver): driver.close() driver.quit() + + +def expressWifi(request,setup_perfectoMobile, connData): + print("\n-------------------------------------") + print("Express Wifi Verification") + print("-------------------------------------") + report = setup_perfectoMobile[1] + driver = setup_perfectoMobile[0] + + try: + print("Express Wifi Home Page Verification") + report.step_start("Express Wifi Home Page Verification") + driver.implicitly_wait(2) + ExpressWifiBytesLeft = driver.find_element_by_xpath("//*[@label='0KB left']") + except NoSuchElementException: + driver.implicitly_wait(25) + #Add function to Toggle Wifi if Express Wifi Home Page not Triggerd + print("Express Wifi Page Not Logged In - ") + + try: + print("ExpressWifi Click on Menu Circle") + report.step_start("ExpressWifi Click on Menu Circle") + ExpressWifiMenu = driver.find_element_by_xpath("//*[@label='⚙️']") + ExpressWifiMenu.click() + except NoSuchElementException: + print("---- Exception ExpressWifi Click on Menu Circle") + + try: + print("ExpressWifi Click Run Tests!") + report.step_start("ExpressWifi Click Run Tests!") + ExpressWifiRunTests = driver.find_element_by_xpath("//*[@resource-id='run_tests']") + ExpressWifiRunTests.click() + time.sleep(20) + except NoSuchElementException: + print("Exception ExceptionExpressWifi Click Run Tests!") + + try: + print("Verify Results: ") + report.step_start("Verify Results") + # ExpressWifiLogMsgCount = driver.find_element_by_xpath("//*[@label='running test ...']/parent::*/XCUIElementTypeStaticText") + # ExpressWifiLogMsg = [] + + # for i in range(1,12): + expressWifiOutputMsg = "//*[@resource-id='test_result']" + LogOut = driver.find_element_by_xpath(expressWifiOutputMsg) + # ExpressWifiLogMsg.append(LogOut.text) + print("----" + LogOut.text + "\n") + # print("ExpressWifiLog: ", ExpressWifiLogMsg) + + except NoSuchElementException: + print("Exception Verify Results") + + try: + print("ExpressWifi Verify Test Complete Msg") + report.step_start("ExpressWifi Verify Test Complete Msg") + ExpressWifiRunTests = driver.find_element_by_xpath("//*[contains (@label,'test completed successfully')]") + + except Exception as e: + assert False + print(" !! ExpressWifi Failure Test Complete Msg") diff --git a/libs/perfecto_libs/iOS_lib.py b/libs/perfecto_libs/iOS_lib.py index 2ed1efc17..8bfdaf7d5 100644 --- a/libs/perfecto_libs/iOS_lib.py +++ b/libs/perfecto_libs/iOS_lib.py @@ -21,18 +21,20 @@ from appium.webdriver.common.mobileby import MobileBy from selenium.webdriver.support import expected_conditions as EC import allure + def openApp(appName, setup_perfectoMobile): - #print("Refreshing App: " + appName) - setup_perfectoMobile[1].step_start("Opening App: " + appName) + # print("Refreshing App: " + appName) + setup_perfectoMobile[1].step_start("Opening App: " + appName) params = {'identifier': appName} - #Open/Close/Open Action is performed to ensure the app is back to its Original Settings + # Open/Close/Open Action is performed to ensure the app is back to its Original Settings setup_perfectoMobile[0].execute_script('mobile:application:open', params) setup_perfectoMobile[0].execute_script('mobile:application:close', params) setup_perfectoMobile[0].execute_script('mobile:application:open', params) + def scrollDown(setup_perfectoMobile): print("Scroll Down") - setup_perfectoMobile[1].step_start("Scroll Down") + setup_perfectoMobile[1].step_start("Scroll Down") params2 = {} params2["start"] = "50%,90%" params2["end"] = "50%,20%" @@ -40,104 +42,109 @@ def scrollDown(setup_perfectoMobile): time.sleep(5) setup_perfectoMobile[0].execute_script('mobile:touch:swipe', params2) time.sleep(5) - + + def closeApp(appName, setup_perfectoMobile): - #print("Closing App.." + appName) - setup_perfectoMobile[1].step_start("Closing App: " + appName) + # print("Closing App.." + appName) + setup_perfectoMobile[1].step_start("Closing App: " + appName) params = {'identifier': appName} setup_perfectoMobile[0].execute_script('mobile:application:close', params) + def rebootPhone(setup_perfectoMobile): - #print("Closing App.." + appName) - setup_perfectoMobile[1].step_start("Rebooting Phone...") + # print("Closing App.." + appName) + setup_perfectoMobile[1].step_start("Rebooting Phone...") params = {} setup_perfectoMobile[0].execute_script('mobile:handset:reboot', params) + def set_APconnMobileDevice_iOS(request, WifiNameSSID, WifiPass, setup_perfectoMobile, connData): consoleOutput = "" print("\n-------------------------------------") print("Select Wifi/AccessPoint Connection") print("-------------------------------------") - + reportFlag = True - - print("Verifying Wifi/AP Connection Details....") - report = setup_perfectoMobile[1] + + print("Verifying Wifi/AP Connection Details....") + report = setup_perfectoMobile[1] driver = setup_perfectoMobile[0] - report.step_start("Switching Driver Context") + report.step_start("Switching Driver Context") print("Switching Context to Native") - #contexts = driver.contexts - #print(contexts) + # contexts = driver.contexts + # print(contexts) driver.switch_to.context('NATIVE_APP') - #driver.switch_to.context(contexts[0]) + # driver.switch_to.context(contexts[0]) print(WifiNameSSID) - report.step_start("Set Wifi Network to " + WifiNameSSID) - #Open Settings Application + report.step_start("Set Wifi Network to " + WifiNameSSID) + # Open Settings Application openApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile) try: print("Verifying Connected Wifi Connection") - report.step_start("Verifying Connected Wifi Connection") + report.step_start("Verifying Connected Wifi Connection") element = driver.find_element_by_xpath("//XCUIElementTypeCell[@name='Wi-Fi']/XCUIElementTypeStaticText[2]") Wifi_AP_Name = element.text except NoSuchElementException: - print("Exception: Verify Xpath - UpdateXpath") - #NEED to fail if Wifi AP NAME isn't in the approved list AKA 5g & 2g. - #print("Wifi Name Matches - Already Connected To: " + Wifi_AP_Name) - #print("Wifi Name Matches - Already Connected To: " + WifiName) + print("Exception: Verify Xpath - UpdateXpath") + # NEED to fail if Wifi AP NAME isn't in the approved list AKA 5g & 2g. + # print("Wifi Name Matches - Already Connected To: " + Wifi_AP_Name) + # print("Wifi Name Matches - Already Connected To: " + WifiName) if Wifi_AP_Name.__eq__(WifiNameSSID): - print("Wifi Name Matches - Already Connected To: " + Wifi_AP_Name) - - #Verify if Ap is connected with Wifi - report.step_start("Verify Wifi Connection Status..") - #print("Click Wifi Connection..") + print("Wifi Name Matches - Already Connected To: " + Wifi_AP_Name) + + # Verify if Ap is connected with Wifi + report.step_start("Verify Wifi Connection Status..") + # print("Click Wifi Connection..") element.click() - #Verifies if AP is connected to Wifi status - #print("Verify Wifi Connection Status..") + # Verifies if AP is connected to Wifi status + # print("Verify Wifi Connection Status..") try: report.step_start("Verify Wifi Connected Status") - WifiXpath = "//*[@label='selected']/parent::*/parent::*/XCUIElementTypeStaticText[@label='"+ Wifi_AP_Name + "']" + WifiXpath = "//*[@label='selected']/parent::*/parent::*/XCUIElementTypeStaticText[@label='" + Wifi_AP_Name + "']" elementWifName = driver.find_element_by_xpath(WifiXpath) except NoSuchElementException: reportFlag = False assert reportFlag - #Check AP Internet Error Msg + # Check AP Internet Error Msg print("Checking Internet Connection Error..") report.step_start("Checking Internet Connection Error..") try: - #WifiInternetErrMsg = driver.find_element_by_xpath("//*[@label='No Internet Connection']").text - NoInternetConnectionMsg = WebDriverWait(driver, 30).until(EC.presence_of_element_located((MobileBy.XPATH, "//*[@label='No Internet Connection']"))) + # WifiInternetErrMsg = driver.find_element_by_xpath("//*[@label='No Internet Connection']").text + NoInternetConnectionMsg = WebDriverWait(driver, 30).until( + EC.presence_of_element_located((MobileBy.XPATH, "//*[@label='No Internet Connection']"))) except Exception as e: print("No Error with Wifi-AP Connection: " + Wifi_AP_Name) else: - print("Selecting Wifi: " + WifiNameSSID) - #consoleOutput+=str(WifiName)+ "\n" + print("Selecting Wifi: " + WifiNameSSID) + # consoleOutput+=str(WifiName)+ "\n" report.step_start("Selecting Wifi...: " + WifiNameSSID) element = driver.find_element_by_xpath("//XCUIElementTypeCell[@name='Wi-Fi']/XCUIElementTypeStaticText[2]") element.click() try: - wifiXpath2 = WebDriverWait(driver, 30).until(EC.presence_of_element_located((MobileBy.XPATH, "//*[@label='"+ WifiNameSSID + "']"))) + wifiXpath2 = WebDriverWait(driver, 30).until( + EC.presence_of_element_located((MobileBy.XPATH, "//*[@label='" + WifiNameSSID + "']"))) wifiXpath2.click() except Exception as e: print("Exception on Selecting Wifi Network. Please check wifi Name or signal") request.config.cache.set(key="SelectingWifiFailed", value=str(e)) - #allure.attach(name="Raj", body="hello world") + # allure.attach(name="Raj", body="hello world") assert False - #Set password if Needed + # Set password if Needed try: wifiPassword = driver.find_element_by_xpath("//*[@label='Password']") wifiPassword.send_keys(WifiPass) except NoSuchElementException: print("Enter Password Page Not Loaded") - + try: joinBTN = driver.find_element_by_xpath("//*[@label='Join']") joinBTN.click() @@ -145,61 +152,63 @@ def set_APconnMobileDevice_iOS(request, WifiNameSSID, WifiPass, setup_perfectoMo print("Join Button Not Enabled...Password may not be needed") try: - 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 + 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 Exception as e: reportFlag = True print("No Wifi-AP Error Internet Error: " + WifiNameSSID) - #Need to add Wait for Selected Wifi Xpath + # Need to add Wait for Selected Wifi Xpath time.sleep(3) return reportFlag + def Toggle_AirplaneMode_iOS(request, setup_perfectoMobile, connData): print("\n-----------------------") print("Toggle Airplane Mode") print("-----------------------") - - report = setup_perfectoMobile[1] + + report = setup_perfectoMobile[1] driver = setup_perfectoMobile[0] currentResult = True - #Open Settings Application + # Open Settings Application openApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile) - #Toggle Airplane Mode + # Toggle Airplane Mode print("Toggle Airplane Mode..") report.step_start("Toggle Airplane Mode") try: AirplaneMode = driver.find_element_by_xpath("//XCUIElementTypeSwitch[@label='Airplane Mode']") - #Toggle Airplane Mode + # Toggle Airplane Mode AirplaneMode.click() - #Verify Cellular Mode Text + # Verify Cellular Mode Text report.step_start("Verify Cellular Mode") try: CellularMsgEle = driver.find_element_by_xpath("//*[@name='Airplane Mode' and @value='Airplane Mode']") - #ssertEqual(CellularMsgEle.text, "Airplane Mode", "Airplane Mode Not Triggerd") + # ssertEqual(CellularMsgEle.text, "Airplane Mode", "Airplane Mode Not Triggerd") print("Verify Cellular Mode Text: Airplane Mode Success") except NoSuchElementException: currentResult = False - print("Cellular Mode Not in Airplane Mode: ERROR") + print("Cellular Mode Not in Airplane Mode: ERROR") - #Set Airplane Mode Back - AirplaneMode.click() + # Set Airplane Mode Back + AirplaneMode.click() except NoSuchElementException: currentResult = False print("Airplane Wifi Button not loaded...") - - #Verify No Sim Card Installed Msg Popup + + # Verify No Sim Card Installed Msg Popup report.step_start("Verify No Sim Card Installed Msg Popup") print("Verify No Sim Card Installed Msg Popup..") try: NoSimCardErrorMsg = driver.find_element_by_xpath("//*[@value='No SIM Card Installed']") except NoSuchElementException: print("No Sim Card AlertMsg") - - #Click ok on No Sim Card Msg Popup + + # Click ok on No Sim Card Msg Popup print("Click ok on No Sim Card Msg Popup..") report.step_start("Click ok on No Sim Card Msg Popup") try: @@ -208,97 +217,102 @@ def Toggle_AirplaneMode_iOS(request, setup_perfectoMobile, connData): except NoSuchElementException: print("No Sim Card AlertMsg") - return currentResult + return currentResult + def verify_APconnMobileDevice_iOS(request, WifiName, setup_perfectoMobile, connData): print("\n-----------------------") print("Verify Connected Wifi Mode") print("-----------------------") - - report = setup_perfectoMobile[1] + + report = setup_perfectoMobile[1] driver = setup_perfectoMobile[0] - report.step_start("Verifying WifiName: " + WifiName) + report.step_start("Verifying WifiName: " + WifiName) - #Refresh Settings Application + # Refresh Settings Application openApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile) - #Verifies if AP is connected to Wifi status + # Verifies if AP is connected to Wifi status try: print("Get Connected Wifi Name") - report.step_start("Get Connected Wifi Name") - element = WebDriverWait(driver, 45).until(EC.presence_of_element_located((MobileBy.XPATH, "//XCUIElementTypeCell[@name='Wi-Fi']/XCUIElementTypeStaticText[2]"))) - #element = driver.find_element_by_xpath("") + report.step_start("Get Connected Wifi Name") + element = WebDriverWait(driver, 45).until(EC.presence_of_element_located( + (MobileBy.XPATH, "//XCUIElementTypeCell[@name='Wi-Fi']/XCUIElementTypeStaticText[2]"))) + # element = driver.find_element_by_xpath("") element.click() - + except Exception as e: print("SSID Not Connected Within allocated Time: " + WifiName) - report.step_start("SSID Not Connected: " + WifiName) + report.step_start("SSID Not Connected: " + WifiName) request.config.cache.set(key="SelectingWifiFailed", value=str(e)) reportFlag = False - assert reportFlag + assert reportFlag - #print("Verifying if SSID Wifi Shows up") - #report.step_start("Verifying if SSID Wifi Shows up") - #wifiXpath2 = WebDriverWait(driver, 45).until(EC.presence_of_element_located((MobileBy.XPATH, "//*[@label='"+ WifiName + "']"))) - #print("SSID is Present: " + WifiName) - #report.step_start("SSID is Present: " + WifiName) + # print("Verifying if SSID Wifi Shows up") + # report.step_start("Verifying if SSID Wifi Shows up") + # wifiXpath2 = WebDriverWait(driver, 45).until(EC.presence_of_element_located((MobileBy.XPATH, "//*[@label='"+ WifiName + "']"))) + # print("SSID is Present: " + WifiName) + # report.step_start("SSID is Present: " + WifiName) - try: + try: print("Waiting for Auto Connection to: " + WifiName) - report.step_start("Waiting for Auto Connection to: " + WifiName) - selectedWifiNetwork = "//*[@label='selected']/parent::*/parent::*/XCUIElementTypeStaticText[@label='"+ WifiName + "']/parent::*/XCUIElementTypeButton[@label='More Info']" - passPointWifi = WebDriverWait(driver, 30).until(EC.presence_of_element_located((MobileBy.XPATH, selectedWifiNetwork))) + report.step_start("Waiting for Auto Connection to: " + WifiName) + selectedWifiNetwork = "//*[@label='selected']/parent::*/parent::*/XCUIElementTypeStaticText[@label='" + WifiName + "']/parent::*/XCUIElementTypeButton[@label='More Info']" + passPointWifi = WebDriverWait(driver, 30).until( + EC.presence_of_element_located((MobileBy.XPATH, selectedWifiNetwork))) except Exception as e: - #Toggle Wifi Mode - Toggle_WifiMode_iOS(request, setup_perfectoMobile, connData) + # Toggle Wifi Mode + Toggle_WifiMode_iOS(request, setup_perfectoMobile, connData) time.sleep(15) try: print("Waiting for Auto Connection After Toggling Wifi: " + WifiName) - selectedWifiNetwork2 = "//*[@label='selected']/parent::*/parent::*/XCUIElementTypeStaticText[@label='"+ WifiName + "']/parent::*/XCUIElementTypeButton[@label='More Info']" - passPointWifi = WebDriverWait(driver, 30).until(EC.presence_of_element_located((MobileBy.XPATH, selectedWifiNetwork2))) + selectedWifiNetwork2 = "//*[@label='selected']/parent::*/parent::*/XCUIElementTypeStaticText[@label='" + WifiName + "']/parent::*/XCUIElementTypeButton[@label='More Info']" + passPointWifi = WebDriverWait(driver, 30).until( + EC.presence_of_element_located((MobileBy.XPATH, selectedWifiNetwork2))) except Exception as e: print("SSID Not Connected Within allocated Time: " + WifiName) - report.step_start("SSID Not Connected: " + WifiName) + report.step_start("SSID Not Connected: " + WifiName) request.config.cache.set(key="SelectingWifiFailed", value=str(e)) reportFlag = False assert reportFlag return True + def ForgetWifiConnection(request, setup_perfectoMobile, wifiName, connData): print("\n-----------------------------") print("Forget Wifi/AP Connection") print("-----------------------------") - - report = setup_perfectoMobile[1] + + report = setup_perfectoMobile[1] driver = setup_perfectoMobile[0] - report.step_start("Switching Driver Context") + report.step_start("Switching Driver Context") print("Switching Context to Native") driver.switch_to.context('NATIVE_APP') - #contexts = driver.contexts - #print(contexts) + # contexts = driver.contexts + # print(contexts) - report.step_start("Forget Existing Wifi") + report.step_start("Forget Existing Wifi") openApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile) try: - # print("Verifying Connected Wifi Connection") - report.step_start("Verifying Existing Connected Wifi Connection") + # print("Verifying Connected Wifi Connection") + report.step_start("Verifying Existing Connected Wifi Connection") element = driver.find_element_by_xpath("//XCUIElementTypeCell[@name='Wi-Fi']/XCUIElementTypeStaticText[2]") Wifi_AP_Name = element.text except NoSuchElementException: - print("Exception: Verify Xpath - UpdateXpath") + print("Exception: Verify Xpath - UpdateXpath") if Wifi_AP_Name.__eq__(wifiName): - print("Wifi Name Matches Connected To: " + Wifi_AP_Name) + print("Wifi Name Matches Connected To: " + Wifi_AP_Name) element.click() print("More Info on Wifi: " + Wifi_AP_Name) report.step_start("Click on More Info on Wifi") - WifiXpathMoreInfo = "//*[@label='selected']/parent::*/parent::*/XCUIElementTypeStaticText[@label='"+ Wifi_AP_Name + "']/parent::*/XCUIElementTypeButton[@label='More Info']" + WifiXpathMoreInfo = "//*[@label='selected']/parent::*/parent::*/XCUIElementTypeStaticText[@label='" + Wifi_AP_Name + "']/parent::*/XCUIElementTypeButton[@label='More Info']" elementMoreInfo = driver.find_element_by_xpath(WifiXpathMoreInfo) elementMoreInfo.click() @@ -315,59 +329,65 @@ def ForgetWifiConnection(request, setup_perfectoMobile, wifiName, connData): elementforgetWifi.click() else: - print("Connected To: " + Wifi_AP_Name) - print("Initial Wifi: " + wifiName) + print("Connected To: " + Wifi_AP_Name) + print("Initial Wifi: " + wifiName) element.click() - report.step_start("Click on More Info on Wifi") - WifiXpathMoreInfo = "//*[@label='selected']/parent::*/parent::*/XCUIElementTypeStaticText[@label='"+ wifiName + "']/parent::*/XCUIElementTypeButton[@label='More Info']" - elementMoreInfo = driver.find_element_by_xpath(WifiXpathMoreInfo) - elementMoreInfo.click() + try: + report.step_start("Click on More Info on Wifi") + WifiXpathMoreInfo = "//*[@label='selected']/parent::*/parent::*/XCUIElementTypeStaticText[@label='" + wifiName + "']/parent::*/XCUIElementTypeButton[@label='More Info']" + elementMoreInfo = driver.find_element_by_xpath(WifiXpathMoreInfo) + elementMoreInfo.click() - print("Forget Wifi Network " + wifiName) - report.step_start("Forget Wifi Network") - WifiXpathForgetWifi = "//*[@label='Forget This Network']" - elementforgetWifi = driver.find_element_by_xpath(WifiXpathForgetWifi) - elementforgetWifi.click() + print("Forget Wifi Network " + wifiName) + report.step_start("Forget Wifi Network") + WifiXpathForgetWifi = "//*[@label='Forget This Network']" + elementforgetWifi = driver.find_element_by_xpath(WifiXpathForgetWifi) + elementforgetWifi.click() + + report.step_start("Confirm Forget Wifi Network") + WifiXpathForgetWifi = "//*[@label='Forget']" + elementforgetWifi = driver.find_element_by_xpath(WifiXpathForgetWifi) + elementforgetWifi.click() + + except NoSuchElementException: + print("Initial Wifi Not Selected: " + wifiName) - report.step_start("Confirm Forget Wifi Network") - WifiXpathForgetWifi = "//*[@label='Forget']" - elementforgetWifi = driver.find_element_by_xpath(WifiXpathForgetWifi) - elementforgetWifi.click() def Toggle_WifiMode_iOS(request, setup_perfectoMobile, connData): print("\n-----------------------") print("Toggle Wifi Mode") print("-----------------------") - - report = setup_perfectoMobile[1] + + report = setup_perfectoMobile[1] driver = setup_perfectoMobile[0] - report.step_start("Toggle Wifi Mode") + report.step_start("Toggle Wifi Mode") print("Toggle Wifi Mode..") try: print("Disable Wifi Radio Btn") - report.step_start("Disable Wifi Radio Btn") + report.step_start("Disable Wifi Radio Btn") WifiMode = driver.find_element_by_xpath("//*[@label='Wi-Fi' and @value='1']") - #Toggle Wifi Mode + # Toggle Wifi Mode WifiMode.click() time.sleep(5) - #Verify Radio Button Mode + # Verify Radio Button Mode try: print("Enable Wifi Radio Btn") - report.step_start("Enable Wifi Radio Btn") + report.step_start("Enable Wifi Radio Btn") WifiDissconnected = driver.find_element_by_xpath("//*[@label='Wi-Fi' and @value='0']") - #self.assertEqual(WifiDissconnected.text, "Airplane Mode", "Airplane Mode Not Triggerd") + # self.assertEqual(WifiDissconnected.text, "Airplane Mode", "Airplane Mode Not Triggerd") print("Wifi Radio Button Toggled to Disable") except NoSuchElementException: - print("Wifi Radio Button Not Disabled...") - - #Set Airplane Mode Back - WifiDissconnected.click() - print("Wifi Radio Button Toggled to Enabled") + print("Wifi Radio Button Not Disabled...") + + # Set Airplane Mode Back + WifiDissconnected.click() + print("Wifi Radio Button Toggled to Enabled") except NoSuchElementException: print("Airplane Wifi Button not loaded...") + def get_WifiIPAddress_iOS(request, setup_perfectoMobile, connData, wifiName): report = setup_perfectoMobile[1] driver = setup_perfectoMobile[0] @@ -375,17 +395,17 @@ def get_WifiIPAddress_iOS(request, setup_perfectoMobile, connData, wifiName): openApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile) try: - # print("Verifying Connected Wifi Connection") - report.step_start("Loading Wifi Page") + # print("Verifying Connected Wifi Connection") + report.step_start("Loading Wifi Page") element = driver.find_element_by_xpath("//XCUIElementTypeCell[@name='Wi-Fi']/XCUIElementTypeStaticText[2]") element.click() except NoSuchElementException: - print("Exception: Verify Xpath - unable to click on Wifi") + print("Exception: Verify Xpath - unable to click on Wifi") report.step_start("Wifi Page") - WifiXpath = "//*[@label='selected']/parent::*/parent::*/XCUIElementTypeStaticText[@label='"+ wifiName + "']" + WifiXpath = "//*[@label='selected']/parent::*/parent::*/XCUIElementTypeStaticText[@label='" + wifiName + "']" elementWifName = driver.find_element_by_xpath(WifiXpath) - #Check AP Internet Error Msg + # Check AP Internet Error Msg print("Checking Internet Connection Error...") report.step_start("Checking Internet Connection Error..") @@ -394,22 +414,24 @@ def get_WifiIPAddress_iOS(request, setup_perfectoMobile, connData, wifiName): except NoSuchElementException: print("Wifi Connected without any errors: " + wifiName) - try: - WifiInternetInfo=driver.find_element_by_xpath("(//XCUIElementTypeButton[@label='More Info'])[1]") + try: + WifiInternetInfo = driver.find_element_by_xpath("(//XCUIElementTypeButton[@label='More Info'])[1]") WifiInternetInfo.click() except NoSuchElementException: print("Wifi-AP Connected Successfully: " + wifiName) - try: - WifiIPaddress= driver.find_element_by_xpath("(//*[@label='Router']/parent::*/XCUIElementTypeStaticText)[2]").text + try: + WifiIPaddress = driver.find_element_by_xpath( + "(//*[@label='Router']/parent::*/XCUIElementTypeStaticText)[2]").text return WifiIPaddress except NoSuchElementException: print("Wifi-AP Connected Successfully: " + wifiName) return None + def ping_deftapps_iOS(setup_perfectoMobile, AP_IPaddress): - report = setup_perfectoMobile[1] + report = setup_perfectoMobile[1] driver = setup_perfectoMobile[0] report.step_start("Pinging deftapps....") @@ -417,10 +439,10 @@ def ping_deftapps_iOS(setup_perfectoMobile, AP_IPaddress): pingHost = "//*[@value='']" element2 = driver.find_element_by_xpath(pingHost) element2.clear() - #element2.send_keys(AP_IPaddress) + # element2.send_keys(AP_IPaddress) element2.send_keys("8.8.8.8") - #Ping Enable + # Ping Enable report.step_start("Pingin Host") print("Pingin Host..") element3 = driver.find_element_by_xpath("//*[@label='go']") @@ -428,7 +450,7 @@ def ping_deftapps_iOS(setup_perfectoMobile, AP_IPaddress): time.sleep(10) - #handle any popup + # handle any popup report.step_start("Stop Ping Host") print("Stop Ping Host..") @@ -439,24 +461,26 @@ def ping_deftapps_iOS(setup_perfectoMobile, AP_IPaddress): report.step_start("Verifying Packet Loss..") print("Verifying Packet Loss..") try: - element5 = driver.find_element_by_xpath("//XCUIElementTypeStaticText[@label='0']") - #assertEqual(element5.text, "0", "Packet Loss Exist, Please Check Device") + element5 = driver.find_element_by_xpath("//XCUIElementTypeStaticText[@label='0']") + # assertEqual(element5.text, "0", "Packet Loss Exist, Please Check Device") except NoSuchElementException: print("No Packet Loss Detected 1st Attempt") report.step_start("Verifying Packet Sent..") print("Verifying Packet Sent..") try: - packetSent = driver.find_element_by_xpath("//XCUIElementTypeStaticText[@label='Sent']/parent::*/XCUIElementTypeStaticText[2]").text - #assertEqual(element5.text, "0", "Packet Loss Exist, Please Check Device") + packetSent = driver.find_element_by_xpath( + "//XCUIElementTypeStaticText[@label='Sent']/parent::*/XCUIElementTypeStaticText[2]").text + # assertEqual(element5.text, "0", "Packet Loss Exist, Please Check Device") except NoSuchElementException: print("-------Exception: Packet Sent Error, check object ID") report.step_start("Verifying Packet Received..") print("Verifying Packet Received..") try: - packetReceived = driver.find_element_by_xpath("//XCUIElementTypeStaticText[@label='Received']/parent::*/XCUIElementTypeStaticText[2]").text - #assertEqual(element5.text, "0", "Packet Loss Exist, Please Check Device") + packetReceived = driver.find_element_by_xpath( + "//XCUIElementTypeStaticText[@label='Received']/parent::*/XCUIElementTypeStaticText[2]").text + # assertEqual(element5.text, "0", "Packet Loss Exist, Please Check Device") except NoSuchElementException: print("-------Exception: Packet Sent Error, check object ID") @@ -466,9 +490,10 @@ def ping_deftapps_iOS(setup_perfectoMobile, AP_IPaddress): print("Verifying No route to host Error Msg....") report.step_start("Verifying No route to host Error Msg..") try: - element7 = driver.find_element_by_xpath("(//XCUIElementTypeStaticText[@label='Sendto: No route to host'])[2]") + element7 = driver.find_element_by_xpath( + "(//XCUIElementTypeStaticText[@label='Sendto: No route to host'])[2]") print("Packet Loss Detected on AP!!!!!: " + AP_IPaddress) - #self.assertNotEqual(element7.text, "Sendto: No route to host", "Packet Loss Exist, Please Check Device AP: " + Wifi_AP_Name) + # self.assertNotEqual(element7.text, "Sendto: No route to host", "Packet Loss Exist, Please Check Device AP: " + Wifi_AP_Name) except NoSuchElementException: print("\nNo Packet Loss Detected on AP!!!!!: " + AP_IPaddress) @@ -477,43 +502,45 @@ def ping_deftapps_iOS(setup_perfectoMobile, AP_IPaddress): return None + def tearDown(setup_perfectoMobile): - report = setup_perfectoMobile[1] + report = setup_perfectoMobile[1] driver = setup_perfectoMobile[0] report.step_start("Exception Failure Tear Down....") try: - print(" -- Tear Down --") + print(" -- Tear Down --") report.test_stop(TestResultFactory.create_failure) print('Report-Url: ' + report.report_url() + '\n') driver.close() except Exception as e: - print(" -- Exception Not Able To close --") - print (e) + print(" -- Exception Not Able To close --") + print(e) finally: try: driver.quit() except Exception as e: - print(" -- Exception Not Able To Quit --") - print (e) + print(" -- Exception Not Able To Quit --") + print(e) + def verifyUploadDownloadSpeediOS(request, setup_perfectoMobile, get_APToMobileDevice_data): print("\n-------------------------------------") print("Verify Upload & Download Speed") print("-------------------------------------") - - report = setup_perfectoMobile[1] + + report = setup_perfectoMobile[1] driver = setup_perfectoMobile[0] connData = get_APToMobileDevice_data currentResult = True contexts = driver.contexts - #print("Printing Context") - #print(contexts) + # print("Printing Context") + # print(contexts) driver.switch_to.context('WEBVIEW_1') - + try: print("Launching Safari") report.step_start("Google Home Page") @@ -543,12 +570,12 @@ def verifyUploadDownloadSpeediOS(request, setup_perfectoMobile, get_APToMobileDe driver.find_element_by_xpath(connData["BtnRunSpeedTest"]).click() except NoSuchElementException: currentResult = False - print("Run Speed Test Button element not found",NoSuchElementException) + print("Run Speed Test Button element not found", NoSuchElementException) return currentResult - #Get upload/Download Speed + # Get upload/Download Speed try: - report.step_start("Get upload/Download Speed") + report.step_start("Get upload/Download Speed") time.sleep(60) downloadMbps = driver.find_element_by_xpath(connData["downloadMbps"]) downloadSpeed = downloadMbps.text @@ -557,39 +584,41 @@ def verifyUploadDownloadSpeediOS(request, setup_perfectoMobile, get_APToMobileDe UploadMbps = driver.find_element_by_xpath(connData["UploadMbps"]) uploadSpeed = UploadMbps.text print("Upload: " + uploadSpeed + " Mbps") - allure.attach(name="Speed Test logs: ", body=str("Upload: " + uploadSpeed + " Mbps" + " Download: " + downloadSpeed + " Mbps")) + allure.attach(name="Speed Test logs: ", + body=str("Upload: " + uploadSpeed + " Mbps" + " Download: " + downloadSpeed + " Mbps")) print("Access Point Verification Completed Successfully") except NoSuchElementException: print("Access Point Verification NOT Completed, checking Connection....") currentResult = False - + return currentResult + def downloadInstallOpenRoamingProfile(request, profileDownloadURL, setup_perfectoMobile, get_APToMobileDevice_data): print("\n-------------------------------------") print("Download Open Roaming Profile") print("-------------------------------------") - + OpenRoamingWifiName = "" - report = setup_perfectoMobile[1] + report = setup_perfectoMobile[1] driver = setup_perfectoMobile[0] connData = get_APToMobileDevice_data currentResult = True contexts = driver.contexts - #print("Printing Context") - #print(contexts) + # print("Printing Context") + # print(contexts) driver.switch_to.context('WEBVIEW_1') - + print("Launching Safari with OpenRoaming Profile") - report.step_start("Open Roaming Download Page") - driver.get(profileDownloadURL) - + report.step_start("Open Roaming Download Page") + driver.get(profileDownloadURL) + try: print("Accept Popup") - report.step_start("Accept Popup") + report.step_start("Accept Popup") driver.switch_to.context('NATIVE_APP') WebDriverWait(driver, 40).until(EC.alert_is_present(), 'Time out confirmation popup to appear') alert = driver.switch_to.alert @@ -597,47 +626,48 @@ def downloadInstallOpenRoamingProfile(request, profileDownloadURL, setup_perfect print("Alert Accepted") except TimeoutException: print("no alert") - - #Open Settings Application + + # Open Settings Application openApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile) try: print("Click on downloaded Profile") - report.step_start("Click on downloaded Profile") - downloadprofile = driver.find_element_by_xpath("//XCUIElementTypeStaticText[@label='Profile Downloaded']") + report.step_start("Click on downloaded Profile") + downloadprofile = driver.find_element_by_xpath("//XCUIElementTypeStaticText[@label='Profile Downloaded']") downloadprofile.click() except NoSuchElementException: print("Exception: Click Download Profile Button not showing up in settings") try: print("Install 1st Confirmation") - report.step_start("Install 1st Confirmation") - install1stConf = driver.find_element_by_xpath("//XCUIElementTypeButton[@label='Install']") + report.step_start("Install 1st Confirmation") + install1stConf = driver.find_element_by_xpath("//XCUIElementTypeButton[@label='Install']") install1stConf.click() except NoSuchElementException: print("Exception: Install 1st Confirmation") - + # //*[@label="The profile is not signed."] try: print("Install 2nd Confirmation") - report.step_start("Install 2nd Confirmation") - install2ndConf = driver.find_element_by_xpath("//XCUIElementTypeButton[@label='Install'] ") + report.step_start("Install 2nd Confirmation") + install2ndConf = driver.find_element_by_xpath("//XCUIElementTypeButton[@label='Install'] ") install2ndConf.click() except NoSuchElementException: print("Exception: Install 2nd Confirmation") try: print("Install 3rd Confirmation") - report.step_start("Install 3rd Confirmation") - install3rdConf = driver.find_element_by_xpath("//XCUIElementTypeButton[@label='Install']") + report.step_start("Install 3rd Confirmation") + install3rdConf = driver.find_element_by_xpath("//XCUIElementTypeButton[@label='Install']") install3rdConf.click() except NoSuchElementException: print("Exception: Install 3rd Confirmation") try: print("Verify Profile Installed") - report.step_start("Verify Profile Installed") - elelSearch2 = WebDriverWait(driver, 30).until(EC.presence_of_element_located((MobileBy.XPATH, "//*[@label='Profile Installed']"))) + report.step_start("Verify Profile Installed") + elelSearch2 = WebDriverWait(driver, 30).until( + EC.presence_of_element_located((MobileBy.XPATH, "//*[@label='Profile Installed']"))) elelSearch2.click() except Exception as e: print("Profile Installed Message Error") @@ -646,8 +676,8 @@ def downloadInstallOpenRoamingProfile(request, profileDownloadURL, setup_perfect try: print("Click Done Button") - report.step_start("Click Done Button") - elelSearch = driver.find_element_by_xpath("//XCUIElementTypeButton[@label='Done']") + report.step_start("Click Done Button") + elelSearch = driver.find_element_by_xpath("//XCUIElementTypeButton[@label='Done']") elelSearch.click() except NoSuchElementException: print("Exception: Clicking on Done Button") @@ -657,97 +687,96 @@ def downloadInstallOpenRoamingProfile(request, profileDownloadURL, setup_perfect print("Switching Context to Webview") driver.switch_to.context('WEBVIEW_1') print("Launching Google to Reset Browser") - report.step_start("Launching Google to Reset Browser") - driver.get("https://www.google.com") + report.step_start("Launching Google to Reset Browser") + driver.get("https://www.google.com") print("Switching Context to Native") - report.step_start("Switching Driver Context Native") + report.step_start("Switching Driver Context Native") driver.switch_to.context('NATIVE_APP') closeApp(connData["bundleId-iOS-Safari"], setup_perfectoMobile) - #Open Settings Application - #openApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile) - - - - # try: - # print("Verifying OpenRoaming Connected Wifi") - # time.sleep(3) - # report.step_start("Verifying Connected Wifi Name") - # element = driver.find_element_by_xpath("//XCUIElementTypeCell[@name='Wi-Fi']/XCUIElementTypeStaticText[2]") - # OpenRoamingWifiName = element.text - # element.click() - - # except Exception as e: - # OpenRoamingWifiName = "None" - # print("Wifi Not Connected to OpenRoaming Profile: ") - # request.config.cache.set(key="SelectingWifiFailed", value=str(e)) - # assert False + # Open Settings Application + # openApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile) +# try: +# print("Verifying OpenRoaming Connected Wifi") +# time.sleep(3) +# report.step_start("Verifying Connected Wifi Name") +# element = driver.find_element_by_xpath("//XCUIElementTypeCell[@name='Wi-Fi']/XCUIElementTypeStaticText[2]") +# OpenRoamingWifiName = element.text +# element.click() - #try: - # report.step_start("Verify Wifi Connected Status") - # WifiXpath = "//*[@label='selected']/parent::*/parent::*/XCUIElementTypeStaticText[@label='"+ OpenRoamingWifiName + "']" - # elementWifName = driver.find_element_by_xpath(WifiXpath) - # OpenRoamingWifiName = elementWifName.text - # print ("Connected to: " + OpenRoamingWifiName) - #except NoSuchElementException: - # OpenRoamingWifiName = "None" - # reportFlag = False - # assert reportFlag +# except Exception as e: +# OpenRoamingWifiName = "None" +# print("Wifi Not Connected to OpenRoaming Profile: ") +# request.config.cache.set(key="SelectingWifiFailed", value=str(e)) +# assert False - #return OpenRoamingWifiName +# try: +# report.step_start("Verify Wifi Connected Status") +# WifiXpath = "//*[@label='selected']/parent::*/parent::*/XCUIElementTypeStaticText[@label='"+ OpenRoamingWifiName + "']" +# elementWifName = driver.find_element_by_xpath(WifiXpath) +# OpenRoamingWifiName = elementWifName.text +# print ("Connected to: " + OpenRoamingWifiName) +# except NoSuchElementException: +# OpenRoamingWifiName = "None" +# reportFlag = False +# assert reportFlag + + +# return OpenRoamingWifiName def ForgetProfileWifiConnection(request, setup_perfectoMobile, installedProfileSSID, connData): print("\n-----------------------------") print("Forget All Wifi/AP Connection") print("-----------------------------") - - report = setup_perfectoMobile[1] + + report = setup_perfectoMobile[1] driver = setup_perfectoMobile[0] - report.step_start("Switching Driver Context") + report.step_start("Switching Driver Context") print("Switching Context to Native") driver.switch_to.context('NATIVE_APP') contexts = driver.contexts - #print(contexts) + # print(contexts) - report.step_start("Forget Existing Wifi") + report.step_start("Forget Existing Wifi") openApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile) try: - #Also have to check with Connected Status xpath + # Also have to check with Connected Status xpath print("Verifying Connected Wifi Connection") - report.step_start("Verifying Existing Connected Wifi Connection") + report.step_start("Verifying Existing Connected Wifi Connection") element22 = driver.find_element_by_xpath("//XCUIElementTypeCell[@name='Wi-Fi']/XCUIElementTypeStaticText[2]") element22.click() - #WifiXpath2= "//*[@label='selected']/parent::*/parent::*/XCUIElementTypeStaticText[2]" - WifiXpath2 = WebDriverWait(driver, 20).until(EC.presence_of_element_located((MobileBy.XPATH, "//*[@label='selected']/parent::*/parent::*/XCUIElementTypeStaticText[2]"))) + # WifiXpath2= "//*[@label='selected']/parent::*/parent::*/XCUIElementTypeStaticText[2]" + WifiXpath2 = WebDriverWait(driver, 20).until(EC.presence_of_element_located( + (MobileBy.XPATH, "//*[@label='selected']/parent::*/parent::*/XCUIElementTypeStaticText[2]"))) elementMoreInfo = driver.find_element_by_xpath(WifiXpath2) Wifi_AP_Name = elementMoreInfo.text - print ("Connected to: " + Wifi_AP_Name) + print("Connected to: " + Wifi_AP_Name) except NoSuchElementException and TimeoutException: Wifi_AP_Name = "None" - print("Wifi Not Connected to anything") + print("Wifi Not Connected to anything") if Wifi_AP_Name.__eq__("Not Connected"): - print("Not Connected to any wifi") - #deleteOpenRoamingInstalledProfile(request, installedProfileSSID, setup_perfectoMobile, connData) + print("Not Connected to any wifi") + # deleteOpenRoamingInstalledProfile(request, installedProfileSSID, setup_perfectoMobile, connData) elif Wifi_AP_Name.__eq__("None"): - #deleteOpenRoamingInstalledProfile(request, installedProfileSSID, setup_perfectoMobile, connData) - print("Not Connected to any wifi Network/None") + # deleteOpenRoamingInstalledProfile(request, installedProfileSSID, setup_perfectoMobile, connData) + print("Not Connected to any wifi Network/None") elif Wifi_AP_Name.__eq__(installedProfileSSID): - deleteOpenRoamingInstalledProfile(request, installedProfileSSID, setup_perfectoMobile, connData) + deleteOpenRoamingInstalledProfile(request, installedProfileSSID, setup_perfectoMobile, connData) else: try: - #element22.click() + # element22.click() report.step_start("Click on More Info on Wifi") - WifiXpathMoreInfo = "//*[@label='selected']/parent::*/parent::*/XCUIElementTypeStaticText[@label='"+ Wifi_AP_Name + "']/parent::*/XCUIElementTypeButton[@label='More Info']" + WifiXpathMoreInfo = "//*[@label='selected']/parent::*/parent::*/XCUIElementTypeStaticText[@label='" + Wifi_AP_Name + "']/parent::*/XCUIElementTypeButton[@label='More Info']" elementMoreInfo = driver.find_element_by_xpath(WifiXpathMoreInfo) elementMoreInfo.click() @@ -763,30 +792,31 @@ def ForgetProfileWifiConnection(request, setup_perfectoMobile, installedProfileS elementforgetWifi.click() except NoSuchElementException: - + print("Exception General Menu Not found") assert False + def deleteOpenRoamingInstalledProfile(request, profileName, setup_perfectoMobile, connData): print("\n-----------------------------") print("Delete Open Roaming Profile") print("-----------------------------") - - report = setup_perfectoMobile[1] + + report = setup_perfectoMobile[1] driver = setup_perfectoMobile[0] - report.step_start("Switching Driver Context") + report.step_start("Switching Driver Context") print("Switching Context to Native") driver.switch_to.context('NATIVE_APP') contexts = driver.contexts - #print(contexts) + # print(contexts) - report.step_start("Forget Existing Wifi") + report.step_start("Forget Existing Wifi") openApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile) try: print("Click General") - report.step_start("Click General") + report.step_start("Click General") element = driver.find_element_by_xpath("//*[@value='General']") element.click() except NoSuchElementException: @@ -799,14 +829,15 @@ def deleteOpenRoamingInstalledProfile(request, profileName, setup_perfectoMobile print("Verify if any Profile Installed ") try: print("Select Profile ") - report.step_start("Select Profile") + report.step_start("Select Profile") elementProfile = driver.find_element_by_xpath("//*[@name='ManagedConfigurationList' and @label='Profile']") elementProfile.click() except NoSuchElementException: - #Verify Multi Profiles + # Verify Multi Profiles print("Multiple Profiles Maybe Installed, Checking Profiles") try: - elementProfiles = driver.find_element_by_xpath("//*[@name='ManagedConfigurationList' and @label='Profiles']") + elementProfiles = driver.find_element_by_xpath( + "//*[@name='ManagedConfigurationList' and @label='Profiles']") elementProfiles.click() print("Exception Select Profile Button") @@ -815,7 +846,7 @@ def deleteOpenRoamingInstalledProfile(request, profileName, setup_perfectoMobile try: print("Click Configuration Profile ") - report.step_start("Click Configuration Profile ") + report.step_start("Click Configuration Profile ") element = driver.find_element_by_xpath("//XCUIElementTypeStaticText[@label='" + profileName + "']") element.click() except NoSuchElementException: @@ -824,16 +855,16 @@ def deleteOpenRoamingInstalledProfile(request, profileName, setup_perfectoMobile try: print("Remove Profile") - report.step_start("Remove Profile ") + report.step_start("Remove Profile ") element = driver.find_element_by_xpath("//*[@label='Remove Profile']") element.click() except NoSuchElementException: print("Exception Remove") assert False - + try: print("Click Remove Button") - report.step_start("Click Remove Button") + report.step_start("Click Remove Button") element = driver.find_element_by_xpath("//*[@label='Remove']") element.click() except Exception as e: @@ -842,11 +873,12 @@ def deleteOpenRoamingInstalledProfile(request, profileName, setup_perfectoMobile except Exception: print("Exception There may be No Profiles Installed") - report.step_start("Exception There may be No Profiles Installed") + report.step_start("Exception There may be No Profiles Installed") closeApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile) -#To get an IP address + +# To get an IP address def get_ip_address_ios(request, WifiName, WifiPass, setup_perfectoMobile, connData): print("\n-------------------------------------") print("Select Wifi/AccessPoint Connection") @@ -869,7 +901,6 @@ def get_ip_address_ios(request, WifiName, WifiPass, setup_perfectoMobile, connDa # Open Settings Application openApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile) - try: time.sleep(2) driver.implicitly_wait(2) @@ -906,11 +937,12 @@ def get_ip_address_ios(request, WifiName, WifiPass, setup_perfectoMobile, connDa break else: try: - get_wifi_switch_element = driver.find_element_by_xpath("//*[@label='Wi-Fi' and @value='0']") + get_wifi_switch_element = driver.find_element_by_xpath( + "//*[@label='Wi-Fi' and @value='0']") get_wifi_switch_element_text = get_wifi_switch_element.text except: print("WIFi switch is ON") - if(get_wifi_switch_element_text == "0" or get_wifi_switch_element_text == 0): + if (get_wifi_switch_element_text == "0" or get_wifi_switch_element_text == 0): print("switch is still OFF") closeApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile) return ip_address_element_text, is_internet @@ -954,7 +986,6 @@ def get_ip_address_ios(request, WifiName, WifiPass, setup_perfectoMobile, connDa except: print("No connected SSID") - # ---------------------This is to Forget current connected SSID------------------------------- # ---------------------To get all available SSID------------------------------- @@ -1034,24 +1065,24 @@ def get_ip_address_ios(request, WifiName, WifiPass, setup_perfectoMobile, connDa # ---------------------Additional INFO------------------------------- try: - print("Selecting SSID: ",WifiName) + print("Selecting SSID: ", WifiName) report.step_start("Selecting SSID") - additional_details_element = WebDriverWait(driver, 30).until( + additional_details_element = WebDriverWait(driver, 30).until( EC.presence_of_element_located((MobileBy.XPATH, - "//*[@label='"+ WifiName+"']"))) + "//*[@label='" + WifiName + "']"))) # //*[@label='selected']/parent::*/parent::*/XCUIElementTypeButton[@label='More Info'] additional_details_element.click() try: print("Checking IP address") # (//*[@label="IP Address"]/parent::*/XCUIElementTypeStaticText)[2] - ip_address_element_text = driver.find_element_by_xpath("(//*[@label='IP Address']/parent::*/XCUIElementTypeStaticText)[2]").text + ip_address_element_text = driver.find_element_by_xpath( + "(//*[@label='IP Address']/parent::*/XCUIElementTypeStaticText)[2]").text print("ip_address_element_text: ", ip_address_element_text) except Exception as e: print("IP Address not Found") request.config.cache.set(key="select IP failed", value=str(e)) - try: time.sleep(2) driver.implicitly_wait(2) @@ -1119,7 +1150,8 @@ def get_ip_address_ios(request, WifiName, WifiPass, setup_perfectoMobile, connDa return ip_address_element_text, is_internet # ---------------------close app------------------------------- -#//XCUIElementTypeOther[2]/XCUIElementTypeOther[1]/XCUIElementTypeStaticText + +# //XCUIElementTypeOther[2]/XCUIElementTypeOther[1]/XCUIElementTypeStaticText def get_all_available_ssids(driver): active_ssid_list = [] try: @@ -1129,13 +1161,14 @@ def get_all_available_ssids(driver): print(len(elements)) for i in range(len(elements)): active_ssid_list.append(elements[i].text) - print("active_ssid_list: ",active_ssid_list ) + print("active_ssid_list: ", active_ssid_list) except: print("No SSIDS available") return active_ssid_list -#Connect to WIFI + +# Connect to WIFI def wifi_connect(request, WifiName, WifiPass, setup_perfectoMobile, connData): print("\n-------------------------------------") print("Select Wifi/AccessPoint Connection") @@ -1317,14 +1350,92 @@ def wifi_connect(request, WifiName, WifiPass, setup_perfectoMobile, connData): # time.sleep(3) # ---------------------check if internet------------------------------- - # --------------------- close app------------------------------- closeApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile) return is_internet # ---------------------close app------------------------------- -#To disconnect and forget network +def expressWifi(request, setup_perfectoMobile, connData): + print("\n-------------------------------------") + print("Express Wifi Verification") + print("-------------------------------------") + report = setup_perfectoMobile[1] + driver = setup_perfectoMobile[0] + + try: + print("Express Wifi Home Page Verification") + report.step_start("Express Wifi Home Page Verification") + driver.implicitly_wait(2) + ExpressWifiBytesLeft = driver.find_element_by_xpath("//*[@label='0KB left']") + except NoSuchElementException: + driver.implicitly_wait(25) + # Add function to Toggle Wifi if Express Wifi Home Page not Triggerd + print("Express Wifi Page Not Logged In - ") + + try: + print("ExpressWifi Click on Menu Circle") + report.step_start("ExpressWifi Click on Menu Circle") + ExpressWifiMenu = driver.find_element_by_xpath("//*[@label='⚙️']") + ExpressWifiMenu.click() + except NoSuchElementException: + print("---- Exception ExpressWifi Click on Menu Circle") + + try: + print("ExpressWifi Click Run Tests!") + report.step_start("ExpressWifi Click Run Tests!") + ExpressWifiRunTests = driver.find_element_by_xpath("//*[@label='Run Tests!']") + ExpressWifiRunTests.click() + time.sleep(20) + except NoSuchElementException: + print("Exception ExceptionExpressWifi Click Run Tests!") + + try: + print("Verify Results: ") + report.step_start("Verify Results") + ExpressWifiLogMsgCount = driver.find_element_by_xpath( + "//*[@label='running test ...']/parent::*/XCUIElementTypeStaticText") + ExpressWifiLogMsg = [] + + for i in range(1, 12): + expressWifiOutputMsg = "//*[@label='running test ...']/parent::*/XCUIElementTypeStaticText[" + str(i) + "]" + LogOut = driver.find_element_by_xpath(expressWifiOutputMsg) + ExpressWifiLogMsg.append(LogOut.text) + print("----" + LogOut.text + "\n") + # print("ExpressWifiLog: ", ExpressWifiLogMsg) + + except NoSuchElementException: + print("Exception Verify Results") + + try: + print("ExpressWifi Verify Test Complete Msg") + report.step_start("ExpressWifi Verify Test Complete Msg") + ExpressWifiRunTests = driver.find_element_by_xpath("//*[contains (@label,'test completed successfully')]") + + except Exception: + assert False + print(" !! ExpressWifi Failure Test Complete Msg") + + # 2)Settings to Logout + + +# try: +# print("Express Wifi Home Page Verification") +## report.step_start("Express Wifi Home Page Verification") +# WifiDissconnected = driver.find_element_by_xpath("//XCUIElementTypeImage[@label='settings']") + +# except NoSuchElementException: +# print("Exception Express Wifi Home Page Verification") + +# 3) +# Logout button +# //*[@label="Log Out"] + +# 4) Confirm Logout +# //*[@label="Log Out All Devices"] + + +# To disconnect and forget network def wifi_disconnect_and_forget(request, WifiName, WifiPass, setup_perfectoMobile, connData): print("\n-------------------------------------") print("Select Wifi/AccessPoint Connection") @@ -1475,8 +1586,8 @@ def wifi_disconnect_and_forget(request, WifiName, WifiPass, setup_perfectoMobile closeApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile) -#To get an IP address -def get_ip_address_eap_ios(request, WifiName ,User, ttls_passwd, setup_perfectoMobile, connData): +# To get an IP address +def get_ip_address_eap_ios(request, WifiName, User, ttls_passwd, setup_perfectoMobile, connData): print("\n-------------------------------------") print("Select Wifi/AccessPoint Connection") print("-------------------------------------") @@ -1498,7 +1609,6 @@ def get_ip_address_eap_ios(request, WifiName ,User, ttls_passwd, setup_perfectoM # Open Settings Application openApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile) - try: time.sleep(2) driver.implicitly_wait(2) @@ -1535,11 +1645,12 @@ def get_ip_address_eap_ios(request, WifiName ,User, ttls_passwd, setup_perfectoM break else: try: - get_wifi_switch_element = driver.find_element_by_xpath("//*[@label='Wi-Fi' and @value='0']") + get_wifi_switch_element = driver.find_element_by_xpath( + "//*[@label='Wi-Fi' and @value='0']") get_wifi_switch_element_text = get_wifi_switch_element.text except: print("WIFi switch is ON") - if(get_wifi_switch_element_text == "0" or get_wifi_switch_element_text == 0): + if (get_wifi_switch_element_text == "0" or get_wifi_switch_element_text == 0): print("switch is still OFF") closeApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile) return ip_address_element_text, is_internet @@ -1583,7 +1694,6 @@ def get_ip_address_eap_ios(request, WifiName ,User, ttls_passwd, setup_perfectoM except: print("No connected SSID") - # ---------------------This is to Forget current connected SSID------------------------------- # ---------------------To get all available SSID------------------------------- @@ -1630,8 +1740,8 @@ def get_ip_address_eap_ios(request, WifiName ,User, ttls_passwd, setup_perfectoM closeApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile) return ip_address_element_text, is_internet # ---------------------This is to Select SSID------------------------------- - # Set username - # ------------------------------------------------------- + # Set username + # ------------------------------------------------------- try: driver.implicitly_wait(5) report.step_start("Entering User") @@ -1652,7 +1762,7 @@ def get_ip_address_eap_ios(request, WifiName ,User, ttls_passwd, setup_perfectoM except NoSuchElementException: print("Enter Password Page Not Loaded") # ---------------------Set Password------------------------------- - # ------------------------------------------------------- + # ------------------------------------------------------- # ---------------------Click on join------------------------------- try: @@ -1664,8 +1774,8 @@ def get_ip_address_eap_ios(request, WifiName ,User, ttls_passwd, setup_perfectoM except Exception as e: print("Join Button Not Enabled...Password may not be needed") # ---------------------Click on join------------------------------- - # Selecting certificate - # ------------------------------------------------------- + # Selecting certificate + # ------------------------------------------------------- try: driver.implicitly_wait(3) report.step_start("Clicking Trust CA Cert") @@ -1690,11 +1800,11 @@ def get_ip_address_eap_ios(request, WifiName ,User, ttls_passwd, setup_perfectoM # ---------------------Additional INFO------------------------------- try: driver.implicitly_wait(5) - print("Selecting SSID: ",WifiName) + print("Selecting SSID: ", WifiName) report.step_start("Selecting SSID") - additional_details_element = WebDriverWait(driver, 35).until( + additional_details_element = WebDriverWait(driver, 35).until( EC.presence_of_element_located((MobileBy.XPATH, - "//*[@label='"+ WifiName+"']"))) + "//*[@label='" + WifiName + "']"))) # //*[@label='selected']/parent::*/parent::*/XCUIElementTypeButton[@label='More Info'] additional_details_element.click() @@ -1704,13 +1814,13 @@ def get_ip_address_eap_ios(request, WifiName ,User, ttls_passwd, setup_perfectoM report.step_start("Checking IP address") time.sleep(4) # (//*[@label="IP Address"]/parent::*/XCUIElementTypeStaticText)[2] - ip_address_element_text = driver.find_element_by_xpath("(//*[@label='IP Address']/parent::*/XCUIElementTypeStaticText)[2]").text + ip_address_element_text = driver.find_element_by_xpath( + "(//*[@label='IP Address']/parent::*/XCUIElementTypeStaticText)[2]").text print("ip_address_element_text: ", ip_address_element_text) except Exception as e: print("IP Address not Found") request.config.cache.set(key="select IP failed", value=str(e)) - try: time.sleep(2) driver.implicitly_wait(2) @@ -1778,6 +1888,7 @@ def get_ip_address_eap_ios(request, WifiName ,User, ttls_passwd, setup_perfectoM return ip_address_element_text, is_internet # ---------------------close app------------------------------- + def wifi_connect_eap(request, WifiName, User, ttls_passwd, setup_perfectoMobile, connData): print("\n-------------------------------------") print("Select Wifi/AccessPoint Connection") @@ -1987,8 +2098,7 @@ def wifi_connect_eap(request, WifiName, User, ttls_passwd, setup_perfectoMobile, # time.sleep(3) # ---------------------check if internet------------------------------- - # --------------------- close app------------------------------- closeApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile) return is_internet - # ---------------------close app------------------------------- + # ---------------------close app------------------------------- \ No newline at end of file diff --git a/tests/fixtures_2x.py b/tests/fixtures_2x.py index 87705022b..2cc02cca8 100644 --- a/tests/fixtures_2x.py +++ b/tests/fixtures_2x.py @@ -508,6 +508,12 @@ class Fixtures_2x: print(e) test_cases["wpa_eap"] = False + try: + if parameter['express-wifi']: + instantiate_profile_obj.set_express_wifi() + except: + pass + ap_ssh = get_apnos(get_configuration['access_point'][0], pwd="../libs/apnos/", sdk="2.x") # Get ucentral status @@ -699,4 +705,3 @@ class Fixtures_2x: pytest.fail("AP is disconnected from UC Gateway") - From 8f17612b2ce73e83b4ff802017f5c0446cb0915c Mon Sep 17 00:00:00 2001 From: sushant Date: Thu, 21 Oct 2021 19:28:18 +0530 Subject: [PATCH 2/6] - e2e for expresswifi - library code changes for android in android_lib.py - Testcases to turn on and off wifi, forget wifi at end of testcases Signed-off-by: Sushant Bawiskar --- libs/perfecto_libs/android_lib.py | 51 +++++++------- tests/e2e/interOp/Express_WiFi/__init__.py | 0 .../interOp/Express_WiFi/android/__init__.py | 0 .../android/test_ExpressWifi_and.py | 66 +++++++++++++++++++ .../e2e/interOp/Express_WiFi/iOS/__init__.py | 0 .../Express_WiFi/iOS/test_ExpressWifi_ios.py | 66 +++++++++++++++++++ 6 files changed, 160 insertions(+), 23 deletions(-) create mode 100644 tests/e2e/interOp/Express_WiFi/__init__.py create mode 100644 tests/e2e/interOp/Express_WiFi/android/__init__.py create mode 100644 tests/e2e/interOp/Express_WiFi/android/test_ExpressWifi_and.py create mode 100644 tests/e2e/interOp/Express_WiFi/iOS/__init__.py create mode 100644 tests/e2e/interOp/Express_WiFi/iOS/test_ExpressWifi_ios.py diff --git a/libs/perfecto_libs/android_lib.py b/libs/perfecto_libs/android_lib.py index f1573a982..6549eccb5 100644 --- a/libs/perfecto_libs/android_lib.py +++ b/libs/perfecto_libs/android_lib.py @@ -1575,7 +1575,7 @@ def wifi_connect(request, WifiName, WifiPass, setup_perfectoMobile, connData): print("Connect Button Not Enabled...Verify if Password is set properly ") check_if_no_internet_popup(driver) # ------------------------------------------------------- - + # //*[@resource-id='com.android.settings:id/summary' and @text="Sign in to the network."]/parent::*/android.widget.TextView[@text='XWF-OWF_DSx'] #Verify if WiFi is connected # ------------------------------------------------------- try: @@ -1607,11 +1607,16 @@ def wifi_connect(request, WifiName, WifiPass, setup_perfectoMobile, connData): ssid_with_internet = True print("Wifi Successfully Connected") #allure.attach(name=body=str("Wifi Successfully Connected")) - except NoSuchElementException: - print("Wifi Connection Error: " + WifiName) - #allure.attach(name=body=str("Wifi Connection Error: " + WifiName)) - closeApp(connData["appPackage-android"], setup_perfectoMobile) - return ssid_with_internet + except: + try: + report.step_start("Unknown WIFI status found") + ssid_with_internet = False + print("Unknown WIFI status found") + except NoSuchElementException: + print("Wifi Connection Error: " + WifiName) + #allure.attach(name=body=str("Wifi Connection Error: " + WifiName)) + closeApp(connData["appPackage-android"], setup_perfectoMobile) + return ssid_with_internet except NoSuchElementException: @@ -2659,7 +2664,7 @@ def wifi_connect_eap(request, WifiName, User, ttls_passwd, setup_perfectoMobile, #allure.attach(name=body=str("Wifi Successfully Connected")) except NoSuchElementException: print("Wifi Connection Error: " + WifiName) - #allure.attach(name=body=str("Wifi Connection Error: " + WifiName)) + #allure.attach(name=body=str("Wifi Connection Error: " + WifiName)) closeApp(connData["appPackage-android"], setup_perfectoMobile) return ssid_with_internet @@ -2687,13 +2692,22 @@ def close_driver(driver): driver.quit() -def expressWifi(request,setup_perfectoMobile, connData): +def expressWifi(request, WifiName, setup_perfectoMobile, connData): print("\n-------------------------------------") print("Express Wifi Verification") print("-------------------------------------") report = setup_perfectoMobile[1] driver = setup_perfectoMobile[0] + try: + click_on_ssid = WebDriverWait(driver, 60).until(EC.presence_of_element_located(( + MobileBy.XPATH, + "//*[@resource-id='com.android.settings:id/summary' and @text='Sign in to the network.']/parent::*/android.widget.TextView[@text='" + WifiName + "']"))) + click_on_ssid.click() + print("click on expresswifi SSID to open login page") + except: + print("Could not found expresswifi SSID") + try: print("Express Wifi Home Page Verification") report.step_start("Express Wifi Home Page Verification") @@ -2707,7 +2721,7 @@ def expressWifi(request,setup_perfectoMobile, connData): try: print("ExpressWifi Click on Menu Circle") report.step_start("ExpressWifi Click on Menu Circle") - ExpressWifiMenu = driver.find_element_by_xpath("//*[@label='⚙️']") + ExpressWifiMenu = driver.find_element_by_xpath("//*[@resource-id='dogfood-menu']") ExpressWifiMenu.click() except NoSuchElementException: print("---- Exception ExpressWifi Click on Menu Circle") @@ -2724,24 +2738,15 @@ def expressWifi(request,setup_perfectoMobile, connData): try: print("Verify Results: ") report.step_start("Verify Results") - # ExpressWifiLogMsgCount = driver.find_element_by_xpath("//*[@label='running test ...']/parent::*/XCUIElementTypeStaticText") - # ExpressWifiLogMsg = [] - # for i in range(1,12): expressWifiOutputMsg = "//*[@resource-id='test_result']" LogOut = driver.find_element_by_xpath(expressWifiOutputMsg) - # ExpressWifiLogMsg.append(LogOut.text) print("----" + LogOut.text + "\n") - # print("ExpressWifiLog: ", ExpressWifiLogMsg) - + if 'test completed successfully' in LogOut.text: + assert True + else: + assert False except NoSuchElementException: print("Exception Verify Results") + closeApp(connData["appPackage-android"], setup_perfectoMobile) - try: - print("ExpressWifi Verify Test Complete Msg") - report.step_start("ExpressWifi Verify Test Complete Msg") - ExpressWifiRunTests = driver.find_element_by_xpath("//*[contains (@label,'test completed successfully')]") - - except Exception as e: - assert False - print(" !! ExpressWifi Failure Test Complete Msg") diff --git a/tests/e2e/interOp/Express_WiFi/__init__.py b/tests/e2e/interOp/Express_WiFi/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/e2e/interOp/Express_WiFi/android/__init__.py b/tests/e2e/interOp/Express_WiFi/android/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/e2e/interOp/Express_WiFi/android/test_ExpressWifi_and.py b/tests/e2e/interOp/Express_WiFi/android/test_ExpressWifi_and.py new file mode 100644 index 000000000..46206ab12 --- /dev/null +++ b/tests/e2e/interOp/Express_WiFi/android/test_ExpressWifi_and.py @@ -0,0 +1,66 @@ +from logging import exception +import unittest +import warnings +from perfecto.test import TestResultFactory +import pytest +import sys +import time +from selenium.common.exceptions import NoSuchElementException +from selenium.webdriver.common.by import By +from appium import webdriver +from selenium.common.exceptions import NoSuchElementException + +import sys +import allure + +if 'perfecto_libs' not in sys.path: + sys.path.append(f'../libs/perfecto_libs') + +pytestmark = [pytest.mark.sanity, pytest.mark.interop, pytest.mark.android, pytest.mark.interop_android, pytest.mark.expressWifiConnection] + +from android_lib import set_APconnMobileDevice_android, ForgetWifiConnection, expressWifi, wifi_connect, wifi_disconnect_and_forget + +setup_params_general = { + "mode": "NAT", + "ssid_modes": { + "open": [{"ssid_name": "XWF-OWF_DSx", "appliedRadios": ["2G"]}] + }, + "rf": {}, + "radius": False, + "express-wifi": True +} + + +@pytest.mark.parametrize( + 'setup_profiles', + [setup_params_general], + indirect=True, + scope="class" +) +@pytest.mark.usefixtures("setup_profiles") +class TestExpressWifiAndroid(object): + + @pytest.mark.twog + @pytest.mark.open + def test_ExpressWifi_Android(self, request, get_ToggleAirplaneMode_data, setup_perfectoMobile_android): + profile_data = setup_params_general["ssid_modes"]["open"][0] + ssidName = profile_data["ssid_name"] + ssidPassword = "" + print ("SSID_NAME: " + ssidName) + print ("SSID_PASS: " + ssidPassword) + + report = setup_perfectoMobile_android[1] + driver = setup_perfectoMobile_android[0] + connData = get_ToggleAirplaneMode_data + + #Set Wifi/AP Mode + wifi_connect(request, ssidName, ssidPassword, setup_perfectoMobile_android, connData) + + #Express Wifi + expressWifi(request, ssidName, setup_perfectoMobile_android, connData) + + #ForgetWifi + wifi_disconnect_and_forget(request, ssidName, ssidPassword, setup_perfectoMobile_android, connData) + + + diff --git a/tests/e2e/interOp/Express_WiFi/iOS/__init__.py b/tests/e2e/interOp/Express_WiFi/iOS/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/e2e/interOp/Express_WiFi/iOS/test_ExpressWifi_ios.py b/tests/e2e/interOp/Express_WiFi/iOS/test_ExpressWifi_ios.py new file mode 100644 index 000000000..20bb051f0 --- /dev/null +++ b/tests/e2e/interOp/Express_WiFi/iOS/test_ExpressWifi_ios.py @@ -0,0 +1,66 @@ +from logging import exception +import unittest +import warnings +from perfecto.test import TestResultFactory +import pytest +import sys +import time +from selenium.common.exceptions import NoSuchElementException +from selenium.webdriver.common.by import By +from appium import webdriver +from selenium.common.exceptions import NoSuchElementException + +import sys +import allure + +if 'perfecto_libs' not in sys.path: + sys.path.append(f'../libs/perfecto_libs') + +pytestmark = [pytest.mark.sanity, pytest.mark.interop, pytest.mark.ios, pytest.mark.interop_ios, + pytest.mark.expressWifiConnection] + +from iOS_lib import closeApp, ForgetWifiConnection, set_APconnMobileDevice_iOS, Toggle_WifiMode_iOS, \ + verifyUploadDownloadSpeediOS, expressWifi, wifi_connect, wifi_disconnect_and_forget + +setup_params_general = { + "mode": "NAT", + "ssid_modes": { + "open": [{"ssid_name": "XWF-OWF_DSx", "appliedRadios": ["2G"]}] + }, + "rf": {}, + "radius": False, + "express-wifi": True +} + + +@pytest.mark.parametrize( + 'setup_profiles', + [setup_params_general], + indirect=True, + scope="class" +) +@pytest.mark.usefixtures("setup_profiles") +class TestExpressWifi(object): + + @pytest.mark.twog + @pytest.mark.open + def test_ExpressWifi(self, request, get_ToggleAirplaneMode_data, setup_perfectoMobile_iOS): + profile_data = setup_params_general["ssid_modes"]["open"][0] + ssidName = profile_data["ssid_name"] + ssidPassword = "" + print("SSID_NAME: " + ssidName) + print("SSID_PASS: " + ssidPassword) + + report = setup_perfectoMobile_iOS[1] + driver = setup_perfectoMobile_iOS[0] + connData = get_ToggleAirplaneMode_data + + # Set Wifi/AP Mode + wifi_connect(request, ssidName, ssidPassword, setup_perfectoMobile_iOS, connData) + + # Express Wifi + expressWifi(request, setup_perfectoMobile_iOS, connData) + + # ForgetWifi + wifi_disconnect_and_forget(request, ssidName, ssidPassword, setup_perfectoMobile_iOS, connData) + From 909c4c73d89657ecae2cd890556ca417a0aa431b Mon Sep 17 00:00:00 2001 From: sushant Date: Tue, 26 Oct 2021 16:24:10 +0530 Subject: [PATCH 3/6] - reduced testcase execution time - refactored configuration Signed-off-by: Sushant Bawiskar --- libs/controller/controller_2x/controller.py | 8 ++++---- libs/perfecto_libs/android_lib.py | 20 ++++++++++--------- libs/perfecto_libs/iOS_lib.py | 7 +++++-- .../android/test_ExpressWifi_and.py | 6 ++++-- .../Express_WiFi/iOS/test_ExpressWifi_ios.py | 6 ++++-- 5 files changed, 28 insertions(+), 19 deletions(-) diff --git a/libs/controller/controller_2x/controller.py b/libs/controller/controller_2x/controller.py index 2aef4a756..2691a41f9 100644 --- a/libs/controller/controller_2x/controller.py +++ b/libs/controller/controller_2x/controller.py @@ -13,7 +13,7 @@ import allure import requests from operator import itemgetter from pathlib import Path -from configuration import EXPRESS_WIFI +from configuration import open_flow from requests.adapters import HTTPAdapter import logging @@ -392,9 +392,9 @@ class UProfileUtility: self.base_profile_config["interfaces"][1]["services"] = ["ssh", "lldp", "open-flow"] self.base_profile_config["interfaces"][1]["ipv4"]["subnet"] = "192.168.97.1/24" self.base_profile_config["interfaces"][1]["ipv4"]["dhcp"]["lease-count"] = 100 - self.base_profile_config['services'] = EXPRESS_WIFI["services"] - self.base_profile_config['metrics']['wifi-frames'] = EXPRESS_WIFI["wifi_frames"] - self.base_profile_config['metrics']['dhcp-snooping'] = EXPRESS_WIFI["dhcp_snooping"] + self.base_profile_config['services']["open-flow"] = open_flow + self.base_profile_config['services']['lldp']['describe'] = "OpenWiFi - expressWiFi" + self.base_profile_config['services']['lldp']['location'] = "Hotspot" diff --git a/libs/perfecto_libs/android_lib.py b/libs/perfecto_libs/android_lib.py index 6549eccb5..eb0a2385b 100644 --- a/libs/perfecto_libs/android_lib.py +++ b/libs/perfecto_libs/android_lib.py @@ -59,9 +59,9 @@ def scrollDown(setup_perfectoMobile): params2["start"] = "50%,90%" params2["end"] = "50%,20%" params2["duration"] = "4" - time.sleep(5) + time.sleep(2) setup_perfectoMobile[0].execute_script('mobile:touch:swipe', params2) - time.sleep(5) + time.sleep(1) def getDeviceID(setup_perfectoMobile): @@ -1063,7 +1063,7 @@ def check_if_no_internet_popup(driver):#To check and kill if any popups related print("**alert** popup **alert**") try: - driver.implicitly_wait(3) + driver.implicitly_wait(2) time.sleep(2) kill_popup = driver.find_element_by_xpath("//*[@resource-id='com.android.settings:id/keep_btn']") kill_popup.click() @@ -1784,8 +1784,8 @@ def wifi_disconnect_and_forget(request, WifiName, WifiPass, setup_perfectoMobile def get_all_available_ssids(driver): active_ssid_list = [] try: - time.sleep(8) - driver.implicitly_wait(10) + time.sleep(5) + driver.implicitly_wait(5) elements = driver.find_elements_by_xpath("//*[@resource-id='com.android.settings:id/title']") # print("elements: ", elements) print(len(elements)) @@ -2700,7 +2700,7 @@ def expressWifi(request, WifiName, setup_perfectoMobile, connData): driver = setup_perfectoMobile[0] try: - click_on_ssid = WebDriverWait(driver, 60).until(EC.presence_of_element_located(( + click_on_ssid = WebDriverWait(driver, 10).until(EC.presence_of_element_located(( MobileBy.XPATH, "//*[@resource-id='com.android.settings:id/summary' and @text='Sign in to the network.']/parent::*/android.widget.TextView[@text='" + WifiName + "']"))) click_on_ssid.click() @@ -2714,7 +2714,7 @@ def expressWifi(request, WifiName, setup_perfectoMobile, connData): driver.implicitly_wait(2) ExpressWifiBytesLeft = driver.find_element_by_xpath("//*[@label='0KB left']") except NoSuchElementException: - driver.implicitly_wait(25) + # driver.implicitly_wait(25) #Add function to Toggle Wifi if Express Wifi Home Page not Triggerd print("Express Wifi Page Not Logged In - ") @@ -2743,9 +2743,11 @@ def expressWifi(request, WifiName, setup_perfectoMobile, connData): LogOut = driver.find_element_by_xpath(expressWifiOutputMsg) print("----" + LogOut.text + "\n") if 'test completed successfully' in LogOut.text: - assert True + closeApp(connData["appPackage-android"], setup_perfectoMobile) + return True else: - assert False + closeApp(connData["appPackage-android"], setup_perfectoMobile) + return False except NoSuchElementException: print("Exception Verify Results") closeApp(connData["appPackage-android"], setup_perfectoMobile) diff --git a/libs/perfecto_libs/iOS_lib.py b/libs/perfecto_libs/iOS_lib.py index 8bfdaf7d5..fcc247823 100644 --- a/libs/perfecto_libs/iOS_lib.py +++ b/libs/perfecto_libs/iOS_lib.py @@ -1369,7 +1369,7 @@ def expressWifi(request, setup_perfectoMobile, connData): driver.implicitly_wait(2) ExpressWifiBytesLeft = driver.find_element_by_xpath("//*[@label='0KB left']") except NoSuchElementException: - driver.implicitly_wait(25) + # driver.implicitly_wait(25) # Add function to Toggle Wifi if Express Wifi Home Page not Triggerd print("Express Wifi Page Not Logged In - ") @@ -1411,10 +1411,13 @@ def expressWifi(request, setup_perfectoMobile, connData): print("ExpressWifi Verify Test Complete Msg") report.step_start("ExpressWifi Verify Test Complete Msg") ExpressWifiRunTests = driver.find_element_by_xpath("//*[contains (@label,'test completed successfully')]") + # closeApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile) + return True except Exception: - assert False + # closeApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile) print(" !! ExpressWifi Failure Test Complete Msg") + return False # 2)Settings to Logout diff --git a/tests/e2e/interOp/Express_WiFi/android/test_ExpressWifi_and.py b/tests/e2e/interOp/Express_WiFi/android/test_ExpressWifi_and.py index 46206ab12..352d536df 100644 --- a/tests/e2e/interOp/Express_WiFi/android/test_ExpressWifi_and.py +++ b/tests/e2e/interOp/Express_WiFi/android/test_ExpressWifi_and.py @@ -57,8 +57,10 @@ class TestExpressWifiAndroid(object): wifi_connect(request, ssidName, ssidPassword, setup_perfectoMobile_android, connData) #Express Wifi - expressWifi(request, ssidName, setup_perfectoMobile_android, connData) - + if expressWifi(request, ssidName, setup_perfectoMobile_android, connData): + assert True + else: + assert False #ForgetWifi wifi_disconnect_and_forget(request, ssidName, ssidPassword, setup_perfectoMobile_android, connData) diff --git a/tests/e2e/interOp/Express_WiFi/iOS/test_ExpressWifi_ios.py b/tests/e2e/interOp/Express_WiFi/iOS/test_ExpressWifi_ios.py index 20bb051f0..42e8800d0 100644 --- a/tests/e2e/interOp/Express_WiFi/iOS/test_ExpressWifi_ios.py +++ b/tests/e2e/interOp/Express_WiFi/iOS/test_ExpressWifi_ios.py @@ -59,8 +59,10 @@ class TestExpressWifi(object): wifi_connect(request, ssidName, ssidPassword, setup_perfectoMobile_iOS, connData) # Express Wifi - expressWifi(request, setup_perfectoMobile_iOS, connData) + if expressWifi(request, setup_perfectoMobile_iOS, connData): + assert True + else: + assert False # ForgetWifi wifi_disconnect_and_forget(request, ssidName, ssidPassword, setup_perfectoMobile_iOS, connData) - From 8cd78d8ef936ce7c7e8628695072a66fa01bd74c Mon Sep 17 00:00:00 2001 From: Dmitry Dunaev Date: Fri, 3 Dec 2021 14:16:50 +0300 Subject: [PATCH 4/6] [WIFI-5919] Chg: make deploy script logic to make services versions optional if chart version is release version Signed-off-by: Dmitry Dunaev --- helm/ucentral/.gitignore | 1 + helm/ucentral/deploy.sh | 67 ++++++++++++++++++++++++---------------- 2 files changed, 41 insertions(+), 27 deletions(-) create mode 100644 helm/ucentral/.gitignore diff --git a/helm/ucentral/.gitignore b/helm/ucentral/.gitignore new file mode 100644 index 000000000..11695a225 --- /dev/null +++ b/helm/ucentral/.gitignore @@ -0,0 +1 @@ +wlan-cloud-ucentral-deploy diff --git a/helm/ucentral/deploy.sh b/helm/ucentral/deploy.sh index dabb26320..c8b1e5f5f 100755 --- a/helm/ucentral/deploy.sh +++ b/helm/ucentral/deploy.sh @@ -9,13 +9,6 @@ usage () { echo "Required environment variables:" echo; echo "- NAMESPACE - namespace suffix that will used added for the Kubernetes environment (i.e. if you pass 'test', kubernetes namespace will be named 'ucentral-test')"; - echo "- OWGW_VERSION - OpenWIFI Gateway version to deploy (will be used for Docker image tag and git branch for Helm chart if git deployment is required)"; - echo "- OWGWUI_VERSION - OpenWIFI Web UI version to deploy (will be used for Docker image tag and git branch for Helm chart if git deployment is required)"; - echo "- OWSEC_VERSION - OpenWIFI Security version to deploy (will be used for Docker image tag and git branch for Helm chart if git deployment is required)"; - echo "- OWFMS_VERSION - OpenWIFI Firmware version to deploy (will be used for Docker image tag and git branch for Helm chart if git deployment is required)"; - echo "- OWPROV_VERSION - OpenWIFI Provisioning version to deploy (will be used for Docker image tag and git branch for Helm chart if git deployment is required)"; - echo "- OWPROVUI_VERSION - OpenWIFI Provisioning Web UI version to deploy (will be used for Docker image tag and git branch for Helm chart if git deployment is required)"; - echo; echo "- DEPLOY_METHOD - deployment method for the chart deployment (supported methods - 'git' (will use helm-git from assembly chart) and 'bundle' (will use chart stored in the Artifactory0"; echo "- CHART_VERSION - version of chart to be deployed from assembly chart (for 'git' method git ref may be passed, for 'bundle' method version of chart may be passed)"; echo; @@ -28,20 +21,44 @@ usage () { echo "- OWSEC_NEW_PASSWORD - password that should be set to default user instead of default password from properties"; echo "- CERT_LOCATION - path to certificate in PEM format that will be used for securing all endpoint in all services"; echo "- KEY_LOCATION - path to private key in PEM format that will be used for securing all endpoint in all services"; + echo; + echo "Following environmnet variables may be passed, but will be ignored if CHART_VERSION is set to release (i.e. v2.4.0):" + echo; + echo "- OWGW_VERSION - OpenWIFI Gateway version to deploy (will be used for Docker image tag and git branch for Helm chart if git deployment is required)"; + echo "- OWGWUI_VERSION - OpenWIFI Web UI version to deploy (will be used for Docker image tag and git branch for Helm chart if git deployment is required)"; + echo "- OWSEC_VERSION - OpenWIFI Security version to deploy (will be used for Docker image tag and git branch for Helm chart if git deployment is required)"; + echo "- OWFMS_VERSION - OpenWIFI Firmware version to deploy (will be used for Docker image tag and git branch for Helm chart if git deployment is required)"; + echo "- OWPROV_VERSION - OpenWIFI Provisioning version to deploy (will be used for Docker image tag and git branch for Helm chart if git deployment is required)"; + echo "- OWPROVUI_VERSION - OpenWIFI Provisioning Web UI version to deploy (will be used for Docker image tag and git branch for Helm chart if git deployment is required)"; +} + +# Helper functions +check_if_chart_version_is_release() { + PARSED_CHART_VERSION=$(echo $CHART_VERSION | grep -xP "v\d+\.\d+\.\d+.*") + if [[ -z "$PARSED_CHART_VERSION" ]]; then + return 1 + else + return 0 + fi } # Check if required environment variables were passed -## Environment specifics -[ -z ${NAMESPACE+x} ] && echo "NAMESPACE is unset" && usage && exit 1 -[ -z ${OWGW_VERSION+x} ] && echo "OWGW_VERSION is unset" && usage && exit 1 -[ -z ${OWGWUI_VERSION+x} ] && echo "OWGWUI_VERSION is unset" && usage && exit 1 -[ -z ${OWSEC_VERSION+x} ] && echo "OWSEC_VERSION is unset" && usage && exit 1 -[ -z ${OWFMS_VERSION+x} ] && echo "OWFMS_VERSION is unset" && usage && exit 1 -[ -z ${OWPROV_VERSION+x} ] && echo "OWPROV_VERSION is unset" && usage && exit 1 -[ -z ${OWPROVUI_VERSION+x} ] && echo "OWPROVUI_VERSION is unset" && usage && exit 1 ## Deployment specifics [ -z ${DEPLOY_METHOD+x} ] && echo "DEPLOY_METHOD is unset" && usage && exit 1 [ -z ${CHART_VERSION+x} ] && echo "CHART_VERSION is unset" && usage && exit 1 +if check_if_chart_version_is_release; then + echo "Chart version ($CHART_VERSION) is release version, ignoring services versions" +else + echo "Chart version ($CHART_VERSION) is not release version, checking if services versions are set" + [ -z ${OWGW_VERSION+x} ] && echo "OWGW_VERSION is unset" && usage && exit 1 + [ -z ${OWGWUI_VERSION+x} ] && echo "OWGWUI_VERSION is unset" && usage && exit 1 + [ -z ${OWSEC_VERSION+x} ] && echo "OWSEC_VERSION is unset" && usage && exit 1 + [ -z ${OWFMS_VERSION+x} ] && echo "OWFMS_VERSION is unset" && usage && exit 1 + [ -z ${OWPROV_VERSION+x} ] && echo "OWPROV_VERSION is unset" && usage && exit 1 + [ -z ${OWPROVUI_VERSION+x} ] && echo "OWPROVUI_VERSION is unset" && usage && exit 1 +fi +## Environment specifics +[ -z ${NAMESPACE+x} ] && echo "NAMESPACE is unset" && usage && exit 1 ## Variables specifics [ -z ${VALUES_FILE_LOCATION+x} ] && echo "VALUES_FILE_LOCATION is unset" && usage && exit 1 [ -z ${RTTY_TOKEN+x} ] && echo "RTTY_TOKEN is unset" && usage && exit 1 @@ -70,12 +87,14 @@ if [[ "$DEPLOY_METHOD" == "git" ]]; then cd wlan-cloud-ucentral-deploy git checkout $CHART_VERSION cd chart - sed -i '/wlan-cloud-ucentralgw@/s/ref=.*/ref='${OWGW_VERSION}'\"/g' Chart.yaml - sed -i '/wlan-cloud-ucentralgw-ui@/s/ref=.*/ref='${OWGWUI_VERSION}'\"/g' Chart.yaml - sed -i '/wlan-cloud-ucentralsec@/s/ref=.*/ref='${OWSEC_VERSION}'\"/g' Chart.yaml - sed -i '/wlan-cloud-ucentralfms@/s/ref=.*/ref='${OWFMS_VERSION}'\"/g' Chart.yaml - sed -i '/wlan-cloud-owprov@/s/ref=.*/ref='${OWPROV_VERSION}'\"/g' Chart.yaml - sed -i '/wlan-cloud-owprov-ui@/s/ref=.*/ref='${OWPROVUI_VERSION}'\"/g' Chart.yaml + if ! check_if_chart_version_is_release; then + sed -i '/wlan-cloud-ucentralgw@/s/ref=.*/ref='${OWGW_VERSION}'\"/g' Chart.yaml + sed -i '/wlan-cloud-ucentralgw-ui@/s/ref=.*/ref='${OWGWUI_VERSION}'\"/g' Chart.yaml + sed -i '/wlan-cloud-ucentralsec@/s/ref=.*/ref='${OWSEC_VERSION}'\"/g' Chart.yaml + sed -i '/wlan-cloud-ucentralfms@/s/ref=.*/ref='${OWFMS_VERSION}'\"/g' Chart.yaml + sed -i '/wlan-cloud-owprov@/s/ref=.*/ref='${OWPROV_VERSION}'\"/g' Chart.yaml + sed -i '/wlan-cloud-owprov-ui@/s/ref=.*/ref='${OWPROVUI_VERSION}'\"/g' Chart.yaml + fi helm repo add bitnami https://charts.bitnami.com/bitnami helm repo update helm dependency update @@ -143,10 +162,4 @@ helm upgrade --install --create-namespace --wait --timeout 60m \ --set-file owfms.certs."restapi-key\.pem"=$KEY_LOCATION \ --set-file owprov.certs."restapi-cert\.pem"=$CERT_LOCATION \ --set-file owprov.certs."restapi-key\.pem"=$KEY_LOCATION \ - --set owgw.images.owgw.tag=$OWGW_VERSION_TAG \ - --set owgwui.images.owgwui.tag=$OWGWUI_VERSION_TAG \ - --set owsec.images.owsec.tag=$OWSEC_VERSION_TAG \ - --set owfms.images.owfms.tag=$OWFMS_VERSION_TAG \ - --set owprov.images.owprov.tag=$OWPROV_VERSION_TAG \ - --set owprovui.images.owprov.tag=$OWPROVUI_VERSION_TAG \ tip-openwifi $DEPLOY_SOURCE From be43b014b2f63cb4deb5dce475c3ee5a336cb47a Mon Sep 17 00:00:00 2001 From: Max Brenner Date: Mon, 6 Dec 2021 10:45:49 +0100 Subject: [PATCH 5/6] fix tr statement --- .github/workflows/quali.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/quali.yml b/.github/workflows/quali.yml index 9e4e15e4b..b3e5bcd2c 100644 --- a/.github/workflows/quali.yml +++ b/.github/workflows/quali.yml @@ -169,7 +169,7 @@ jobs: - name: prepare namespace id: namespace run: | - NAMESPACE="testing-${{ github.run_id }}-$(echo ${{ matrix.ap_model }} | tr '[:upper:]' '[:lower:]')" | tr "_" "-" + NAMESPACE="testing-${{ github.run_id }}-$(echo ${{ matrix.ap_model }} | tr '[:upper:]' '[:lower:]' | tr '_' '-')" kubectl create ns $NAMESPACE kubectl config set-context --current --namespace=$NAMESPACE echo "::set-output name=name::${NAMESPACE}" From 74555dce963c3bc9356010ad57392dd6c61df925 Mon Sep 17 00:00:00 2001 From: Max Brenner Date: Mon, 6 Dec 2021 17:39:21 +0100 Subject: [PATCH 6/6] fix gw config value Signed-off-by: Max Brenner --- helm/ucentral/values.ucentral-qa.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/ucentral/values.ucentral-qa.yaml b/helm/ucentral/values.ucentral-qa.yaml index a2dfe5d0a..a7e06d7a1 100644 --- a/helm/ucentral/values.ucentral-qa.yaml +++ b/helm/ucentral/values.ucentral-qa.yaml @@ -22,7 +22,7 @@ owgw: # -> Public part # File uploader # rtty - rtty.enabled: ["true"] + rtty.enabled: "true" resources: requests: