Merge branch 'WIFI-3916' of https://github.com/Telecominfraproject/wlan-testing into WIFI-3916

This commit is contained in:
Nikita Yadav
2021-12-06 23:25:53 +05:30
13 changed files with 545 additions and 189 deletions

View File

@@ -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}"

1
helm/ucentral/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
wlan-cloud-ucentral-deploy

View File

@@ -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

View File

@@ -22,7 +22,7 @@ owgw:
# -> Public part
# File uploader
# rtty
rtty.enabled: ["true"]
rtty.enabled: "true"
resources:
requests:

View File

@@ -13,6 +13,7 @@ import allure
import requests
from operator import itemgetter
from pathlib import Path
from configuration import open_flow
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']["open-flow"] = open_flow
self.base_profile_config['services']['lldp']['describe'] = "OpenWiFi - expressWiFi"
self.base_profile_config['services']['lldp']['location'] = "Hotspot"
def encryption_lookup(self, encryption="psk"):
encryption_mapping = {
"none": "open",

View File

@@ -60,9 +60,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):
@@ -115,6 +115,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")
@@ -144,6 +146,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)
@@ -1061,7 +1064,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()
@@ -1573,7 +1576,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:
@@ -1605,11 +1608,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:
@@ -1777,8 +1785,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))
@@ -2657,7 +2665,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
@@ -3317,13 +3325,65 @@ def close_driver(driver):
driver.close()
driver.quit()
# def capture_start_har(setup_perfectoMobile):
# setup_perfectoMobile[1].step_start("Start HAR capture on Phone...")
# # params = {'generateHarFile', 'true'}
# params = {'generateHarFile' : 'true'}
# setup_perfectoMobile[0].execute_script('mobile:vnetwork:start', params)
#
# def capture_stop_har(setup_perfectoMobile):
# setup_perfectoMobile[1].step_start("Stop HAR capture on Phone...")
# params = {'generateHarFile' : 'true'}
# setup_perfectoMobile[0].execute_script('mobile:vnetwork:stop', params)
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, 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()
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")
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("//*[@resource-id='dogfood-menu']")
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")
expressWifiOutputMsg = "//*[@resource-id='test_result']"
LogOut = driver.find_element_by_xpath(expressWifiOutputMsg)
print("----" + LogOut.text + "\n")
if 'test completed successfully' in LogOut.text:
closeApp(connData["appPackage-android"], setup_perfectoMobile)
return True
else:
closeApp(connData["appPackage-android"], setup_perfectoMobile)
return False
except NoSuchElementException:
print("Exception Verify Results")
closeApp(connData["appPackage-android"], setup_perfectoMobile)

View File

@@ -21,15 +21,16 @@ 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)
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")
@@ -41,18 +42,20 @@ def scrollDown(setup_perfectoMobile):
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)
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...")
params = {}
setup_perfectoMobile[0].execute_script('mobile:handset:reboot', params)
def set_APconnMobileDevice_iOS(request, WifiNameSSID, WifiPass, setup_perfectoMobile, connData):
consoleOutput = ""
@@ -68,14 +71,14 @@ def set_APconnMobileDevice_iOS(request, WifiNameSSID, WifiPass, setup_perfectoMo
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
openApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile)
try:
@@ -85,53 +88,54 @@ def set_APconnMobileDevice_iOS(request, WifiNameSSID, WifiPass, setup_perfectoMo
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)
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..")
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
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"
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)
@@ -145,16 +149,18 @@ 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")
@@ -164,34 +170,34 @@ def Toggle_AirplaneMode_iOS(request, setup_perfectoMobile, connData):
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")
#Set Airplane Mode Back
AirplaneMode.click()
except NoSuchElementException:
currentResult = False
print("Airplane Wifi Button not loaded...")
#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:
@@ -199,7 +205,7 @@ def Toggle_AirplaneMode_iOS(request, setup_perfectoMobile, connData):
except NoSuchElementException:
print("No Sim Card AlertMsg")
#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,7 +214,8 @@ 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-----------------------")
@@ -220,15 +227,17 @@ def verify_APconnMobileDevice_iOS(request, WifiName, setup_perfectoMobile, connD
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("")
element.click()
except Exception as e:
@@ -238,15 +247,12 @@ def verify_APconnMobileDevice_iOS(request, WifiName, setup_perfectoMobile, connD
reportFlag = False
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)
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)))
except Exception as e:
@@ -256,8 +262,9 @@ def verify_APconnMobileDevice_iOS(request, WifiName, setup_perfectoMobile, connD
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)
@@ -267,6 +274,7 @@ def verify_APconnMobileDevice_iOS(request, WifiName, setup_perfectoMobile, connD
return True
def ForgetWifiConnection(request, setup_perfectoMobile, wifiName, connData):
print("\n-----------------------------")
print("Forget Wifi/AP Connection")
@@ -278,14 +286,14 @@ def ForgetWifiConnection(request, setup_perfectoMobile, wifiName, connData):
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")
openApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile)
try:
# 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
@@ -298,7 +306,7 @@ def ForgetWifiConnection(request, setup_perfectoMobile, wifiName, connData):
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()
@@ -319,21 +327,26 @@ def ForgetWifiConnection(request, setup_perfectoMobile, wifiName, connData):
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-----------------------")
@@ -349,25 +362,26 @@ def Toggle_WifiMode_iOS(request, setup_perfectoMobile, connData):
print("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")
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")
except NoSuchElementException:
print("Airplane Wifi Button not loaded...")
def get_WifiIPAddress_iOS(request, setup_perfectoMobile, connData, wifiName):
print("\n------------------------------------")
print("Get Wifi IP Address IOS")
@@ -379,7 +393,7 @@ 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")
element = driver.find_element_by_xpath("//XCUIElementTypeCell[@name='Wi-Fi']/XCUIElementTypeStaticText[2]")
element.click()
@@ -387,9 +401,9 @@ def get_WifiIPAddress_iOS(request, setup_perfectoMobile, connData, wifiName):
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
print("Checking Internet Connection Error...")
report.step_start("Checking Internet Connection Error..")
@@ -399,19 +413,24 @@ def get_WifiIPAddress_iOS(request, setup_perfectoMobile, connData, wifiName):
print("Wifi Connected without any errors: " + wifiName)
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
return WifiIPaddress
except NoSuchElementException:
print("Wifi-AP Connected Successfully: " + wifiName)
return None
def ping_deftapps_iOS(setup_perfectoMobile, AP_IPaddress):
report = setup_perfectoMobile[1]
driver = setup_perfectoMobile[0]
@@ -421,10 +440,10 @@ def ping_deftapps_iOS(setup_perfectoMobile, AP_IPaddress):
pingHost = "//*[@value='<Hostname or IP address>']"
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']")
@@ -432,7 +451,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..")
@@ -444,23 +463,27 @@ def ping_deftapps_iOS(setup_perfectoMobile, AP_IPaddress):
print("Verifying Packet Loss..")
try:
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")
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")
except NoSuchElementException:
print("-------Exception: Packet Sent Error, check object ID")
@@ -470,9 +493,11 @@ 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]")
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)
@@ -481,6 +506,7 @@ def ping_deftapps_iOS(setup_perfectoMobile, AP_IPaddress):
return None
def tearDown(setup_perfectoMobile):
report = setup_perfectoMobile[1]
driver = setup_perfectoMobile[0]
@@ -494,14 +520,18 @@ def tearDown(setup_perfectoMobile):
driver.close()
except Exception as 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)
def verifyUploadDownloadSpeediOS(request, setup_perfectoMobile, get_APToMobileDevice_data):
print("\n-------------------------------------")
print("Verify Upload & Download Speed")
@@ -513,8 +543,8 @@ def verifyUploadDownloadSpeediOS(request, setup_perfectoMobile, get_APToMobileDe
currentResult = True
contexts = driver.contexts
#print("Printing Context")
#print(contexts)
# print("Printing Context")
# print(contexts)
driver.switch_to.context('WEBVIEW_1')
@@ -547,10 +577,10 @@ 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")
time.sleep(60)
@@ -561,7 +591,8 @@ 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:
@@ -570,6 +601,7 @@ def verifyUploadDownloadSpeediOS(request, setup_perfectoMobile, get_APToMobileDe
return currentResult
def downloadInstallOpenRoamingProfile(request, profileDownloadURL, setup_perfectoMobile, get_APToMobileDevice_data):
print("\n-------------------------------------")
print("Download Open Roaming Profile")
@@ -582,8 +614,8 @@ def downloadInstallOpenRoamingProfile(request, profileDownloadURL, setup_perfect
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')
@@ -602,7 +634,7 @@ def downloadInstallOpenRoamingProfile(request, profileDownloadURL, setup_perfect
except TimeoutException:
print("no alert")
#Open Settings Application
openApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile)
try:
@@ -641,7 +673,9 @@ def downloadInstallOpenRoamingProfile(request, profileDownloadURL, setup_perfect
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']")))
elelSearch2.click()
except Exception as e:
print("Profile Installed Message Error")
@@ -670,8 +704,9 @@ def downloadInstallOpenRoamingProfile(request, profileDownloadURL, setup_perfect
closeApp(connData["bundleId-iOS-Safari"], setup_perfectoMobile)
#Open Settings Application
#openApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile)
# Open Settings Application
# openApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile)
@@ -689,21 +724,26 @@ def downloadInstallOpenRoamingProfile(request, profileDownloadURL, setup_perfect
# request.config.cache.set(key="SelectingWifiFailed", value=str(e))
# assert False
# except Exception as e:
# OpenRoamingWifiName = "None"
# print("Wifi Not Connected to OpenRoaming Profile: ")
# request.config.cache.set(key="SelectingWifiFailed", value=str(e))
# assert False
#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
# 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
# return OpenRoamingWifiName
def ForgetProfileWifiConnection(request, setup_perfectoMobile, installedProfileSSID, connData):
print("\n-----------------------------")
@@ -717,23 +757,24 @@ def ForgetProfileWifiConnection(request, setup_perfectoMobile, installedProfileS
print("Switching Context to Native")
driver.switch_to.context('NATIVE_APP')
contexts = driver.contexts
#print(contexts)
# print(contexts)
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")
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"
@@ -741,17 +782,19 @@ def ForgetProfileWifiConnection(request, setup_perfectoMobile, installedProfileS
if Wifi_AP_Name.__eq__("Not Connected"):
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")
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()
@@ -771,6 +814,7 @@ def ForgetProfileWifiConnection(request, setup_perfectoMobile, installedProfileS
print("Exception General Menu Not found")
assert False
def deleteOpenRoamingInstalledProfile(request, profileName, setup_perfectoMobile, connData):
print("\n-----------------------------")
print("Delete Open Roaming Profile")
@@ -783,7 +827,7 @@ def deleteOpenRoamingInstalledProfile(request, profileName, setup_perfectoMobile
print("Switching Context to Native")
driver.switch_to.context('NATIVE_APP')
contexts = driver.contexts
#print(contexts)
# print(contexts)
report.step_start("Forget Existing Wifi")
openApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile)
@@ -807,10 +851,11 @@ def deleteOpenRoamingInstalledProfile(request, profileName, setup_perfectoMobile
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")
@@ -850,7 +895,8 @@ def deleteOpenRoamingInstalledProfile(request, profileName, setup_perfectoMobile
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/Get IP Address IOS Connection")
@@ -873,7 +919,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)
@@ -910,11 +955,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
@@ -958,7 +1004,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-------------------------------
@@ -1038,24 +1083,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)
@@ -1123,7 +1168,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):
print("\n----------------------------")
print("Get All Available SSID")
@@ -1137,13 +1183,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 Connect Connection")
@@ -1325,14 +1372,95 @@ 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')]")
# closeApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile)
return True
except Exception:
# closeApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile)
print(" !! ExpressWifi Failure Test Complete Msg")
return False
# 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("Wifi Disconnect and Forget Connection")
@@ -1483,8 +1611,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("Get IP Address Enterprise IOS Connection")
print("-------------------------------------")
@@ -1506,7 +1634,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)
@@ -1543,11 +1670,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
@@ -1591,7 +1719,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-------------------------------
@@ -1638,8 +1765,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")
@@ -1660,7 +1787,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:
@@ -1672,8 +1799,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")
@@ -1698,11 +1825,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()
@@ -1712,13 +1839,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)
@@ -1786,6 +1913,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("Wifi Connect Enterprise Connection")
@@ -1995,10 +2123,10 @@ 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-------------------------------
#Captive Portal
@@ -2257,4 +2385,4 @@ def captive_portal_ios(request, WifiName, WifiPass, setup_perfectoMobile, connDa
# --------------------- close app-------------------------------
#closeApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile)
return ip_address_element_text, is_internet
return ip_address_element_text, is_internet

View File

@@ -0,0 +1,68 @@
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
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)

View File

@@ -0,0 +1,68 @@
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
if expressWifi(request, setup_perfectoMobile_iOS, connData):
assert True
else:
assert False
# ForgetWifi
wifi_disconnect_and_forget(request, ssidName, ssidPassword, setup_perfectoMobile_iOS, connData)

View File

@@ -561,6 +561,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
@@ -753,4 +759,3 @@ class Fixtures_2x:
pytest.fail("AP is disconnected from UC Gateway")