mirror of
https://github.com/Telecominfraproject/wlan-testing.git
synced 2025-11-02 03:48:09 +00:00
Merge branch 'master' into WIFI-4951
This commit is contained in:
@@ -23,7 +23,6 @@ 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
|
||||
@@ -45,14 +44,13 @@ def scrollDown(setup_perfectoMobile):
|
||||
|
||||
|
||||
def closeApp(appName, setup_perfectoMobile):
|
||||
# print("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...")
|
||||
params = {}
|
||||
setup_perfectoMobile[0].execute_script('mobile:handset:reboot', params)
|
||||
@@ -80,7 +78,7 @@ def set_APconnMobileDevice_iOS(request, WifiNameSSID, WifiPass, setup_perfectoMo
|
||||
|
||||
print(WifiNameSSID)
|
||||
report.step_start("Set Wifi Network to " + WifiNameSSID)
|
||||
# Open Settings Application
|
||||
|
||||
openApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile)
|
||||
|
||||
try:
|
||||
@@ -90,16 +88,15 @@ 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
|
||||
|
||||
#Verify if Ap is connected with Wifi
|
||||
report.step_start("Verify Wifi Connection Status..")
|
||||
# print("Click Wifi Connection..")
|
||||
#print("Click Wifi Connection..")
|
||||
element.click()
|
||||
|
||||
# Verifies if AP is connected to Wifi status
|
||||
@@ -112,7 +109,7 @@ def set_APconnMobileDevice_iOS(request, WifiNameSSID, WifiPass, setup_perfectoMo
|
||||
reportFlag = False
|
||||
assert reportFlag
|
||||
|
||||
# Check AP Internet Error Msg
|
||||
|
||||
print("Checking Internet Connection Error..")
|
||||
report.step_start("Checking Internet Connection Error..")
|
||||
|
||||
@@ -125,7 +122,7 @@ def set_APconnMobileDevice_iOS(request, WifiNameSSID, WifiPass, setup_perfectoMo
|
||||
|
||||
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()
|
||||
@@ -194,13 +191,13 @@ def Toggle_AirplaneMode_iOS(request, setup_perfectoMobile, connData):
|
||||
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:
|
||||
@@ -208,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:
|
||||
@@ -237,9 +234,10 @@ def verify_APconnMobileDevice_iOS(request, WifiName, setup_perfectoMobile, connD
|
||||
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 = 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:
|
||||
@@ -249,20 +247,16 @@ 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)))
|
||||
|
||||
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 Wifi Mode
|
||||
Toggle_WifiMode_iOS(request, setup_perfectoMobile, connData)
|
||||
time.sleep(15)
|
||||
|
||||
@@ -299,7 +293,7 @@ def ForgetWifiConnection(request, setup_perfectoMobile, wifiName, connData):
|
||||
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
|
||||
@@ -381,7 +375,7 @@ def Toggle_WifiMode_iOS(request, setup_perfectoMobile, connData):
|
||||
except NoSuchElementException:
|
||||
print("Wifi Radio Button Not Disabled...")
|
||||
|
||||
# Set Airplane Mode Back
|
||||
|
||||
WifiDissconnected.click()
|
||||
print("Wifi Radio Button Toggled to Enabled")
|
||||
except NoSuchElementException:
|
||||
@@ -389,13 +383,17 @@ def Toggle_WifiMode_iOS(request, setup_perfectoMobile, connData):
|
||||
|
||||
|
||||
def get_WifiIPAddress_iOS(request, setup_perfectoMobile, connData, wifiName):
|
||||
print("\n------------------------------------")
|
||||
print("Get Wifi IP Address IOS")
|
||||
print("--------------------------------------")
|
||||
|
||||
report = setup_perfectoMobile[1]
|
||||
driver = setup_perfectoMobile[0]
|
||||
|
||||
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()
|
||||
@@ -405,7 +403,7 @@ def get_WifiIPAddress_iOS(request, setup_perfectoMobile, connData, wifiName):
|
||||
report.step_start("Wifi Page")
|
||||
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..")
|
||||
|
||||
@@ -415,14 +413,17 @@ 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=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
|
||||
|
||||
WifiIPaddress= driver.find_element_by_xpath("(//*[@label='Router']/parent::*/XCUIElementTypeStaticText)[2]").text
|
||||
|
||||
return WifiIPaddress
|
||||
except NoSuchElementException:
|
||||
print("Wifi-AP Connected Successfully: " + wifiName)
|
||||
@@ -462,25 +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")
|
||||
|
||||
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")
|
||||
|
||||
@@ -490,8 +493,9 @@ 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)
|
||||
except NoSuchElementException:
|
||||
@@ -516,13 +520,16 @@ def tearDown(setup_perfectoMobile):
|
||||
driver.close()
|
||||
except Exception as e:
|
||||
print(" -- Exception Not Able To close --")
|
||||
print(e)
|
||||
|
||||
print (e)
|
||||
|
||||
finally:
|
||||
try:
|
||||
driver.quit()
|
||||
except Exception as e:
|
||||
print(" -- Exception Not Able To Quit --")
|
||||
print(e)
|
||||
|
||||
print (e)
|
||||
|
||||
|
||||
def verifyUploadDownloadSpeediOS(request, setup_perfectoMobile, get_APToMobileDevice_data):
|
||||
@@ -627,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:
|
||||
@@ -666,8 +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 = 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")
|
||||
@@ -700,13 +708,21 @@ def downloadInstallOpenRoamingProfile(request, profileDownloadURL, setup_perfect
|
||||
# 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:
|
||||
# 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
|
||||
|
||||
# except Exception as e:
|
||||
# OpenRoamingWifiName = "None"
|
||||
@@ -766,9 +782,11 @@ 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)
|
||||
|
||||
#deleteOpenRoamingInstalledProfile(request, installedProfileSSID, setup_perfectoMobile, connData)
|
||||
elif Wifi_AP_Name.__eq__("None"):
|
||||
# deleteOpenRoamingInstalledProfile(request, installedProfileSSID, setup_perfectoMobile, connData)
|
||||
#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)
|
||||
@@ -881,7 +899,7 @@ def deleteOpenRoamingInstalledProfile(request, profileName, setup_perfectoMobile
|
||||
# To get an IP address
|
||||
def get_ip_address_ios(request, WifiName, WifiPass, setup_perfectoMobile, connData):
|
||||
print("\n-------------------------------------")
|
||||
print("Select Wifi/AccessPoint Connection")
|
||||
print("Select Wifi/Get IP Address IOS Connection")
|
||||
print("-------------------------------------")
|
||||
|
||||
reportFlag = True
|
||||
@@ -1153,6 +1171,10 @@ def get_ip_address_ios(request, WifiName, WifiPass, setup_perfectoMobile, connDa
|
||||
|
||||
# //XCUIElementTypeOther[2]/XCUIElementTypeOther[1]/XCUIElementTypeStaticText
|
||||
def get_all_available_ssids(driver):
|
||||
print("\n----------------------------")
|
||||
print("Get All Available SSID")
|
||||
print("------------------------------")
|
||||
|
||||
active_ssid_list = []
|
||||
try:
|
||||
time.sleep(8)
|
||||
@@ -1171,7 +1193,7 @@ def get_all_available_ssids(driver):
|
||||
# Connect to WIFI
|
||||
def wifi_connect(request, WifiName, WifiPass, setup_perfectoMobile, connData):
|
||||
print("\n-------------------------------------")
|
||||
print("Select Wifi/AccessPoint Connection")
|
||||
print("Select Wifi Connect Connection")
|
||||
print("-------------------------------------")
|
||||
|
||||
reportFlag = True
|
||||
@@ -1441,7 +1463,7 @@ def expressWifi(request, setup_perfectoMobile, connData):
|
||||
# To disconnect and forget network
|
||||
def wifi_disconnect_and_forget(request, WifiName, WifiPass, setup_perfectoMobile, connData):
|
||||
print("\n-------------------------------------")
|
||||
print("Select Wifi/AccessPoint Connection")
|
||||
print("Wifi Disconnect and Forget Connection")
|
||||
print("-------------------------------------")
|
||||
|
||||
reportFlag = True
|
||||
@@ -1592,7 +1614,7 @@ def wifi_disconnect_and_forget(request, WifiName, WifiPass, setup_perfectoMobile
|
||||
# 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("Get IP Address Enterprise IOS Connection")
|
||||
print("-------------------------------------")
|
||||
|
||||
reportFlag = True
|
||||
@@ -1894,7 +1916,7 @@ def get_ip_address_eap_ios(request, WifiName, User, ttls_passwd, setup_perfectoM
|
||||
|
||||
def wifi_connect_eap(request, WifiName, User, ttls_passwd, setup_perfectoMobile, connData):
|
||||
print("\n-------------------------------------")
|
||||
print("Select Wifi/AccessPoint Connection")
|
||||
print("Wifi Connect Enterprise Connection")
|
||||
print("-------------------------------------")
|
||||
|
||||
reportFlag = True
|
||||
@@ -2104,4 +2126,263 @@ def wifi_connect_eap(request, WifiName, User, ttls_passwd, setup_perfectoMobile,
|
||||
# --------------------- close app-------------------------------
|
||||
closeApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile)
|
||||
return is_internet
|
||||
# ---------------------close app-------------------------------
|
||||
|
||||
# ---------------------close app-------------------------------
|
||||
|
||||
#Captive Portal
|
||||
def captive_portal_ios(request, WifiName, WifiPass, setup_perfectoMobile, connData):
|
||||
print("\n-------------------------------------")
|
||||
print("CaptivePortal Connection IOS")
|
||||
print("-------------------------------------")
|
||||
|
||||
reportFlag = True
|
||||
is_internet = False
|
||||
ip_address_element_text = False
|
||||
|
||||
print("Verifying Wifi/AP Connection Details....")
|
||||
report = setup_perfectoMobile[1]
|
||||
driver = setup_perfectoMobile[0]
|
||||
|
||||
report.step_start("Switching Driver Context")
|
||||
print("Switching Context to Native")
|
||||
driver.switch_to.context('NATIVE_APP')
|
||||
# driver.switch_to.context(contexts[0])
|
||||
|
||||
report.step_start("Set Wifi Network to " + WifiName)
|
||||
# Open Settings Application
|
||||
openApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile)
|
||||
|
||||
try:
|
||||
time.sleep(2)
|
||||
driver.implicitly_wait(2)
|
||||
try:
|
||||
print("Verifying Connected Wifi Connection")
|
||||
report.step_start("Loading Wifi Page")
|
||||
element = driver.find_element_by_xpath("//XCUIElementTypeCell[@name='Wi-Fi']")
|
||||
element.click()
|
||||
except NoSuchElementException:
|
||||
print("Exception: Verify Xpath - unable to click on Wifi")
|
||||
|
||||
time.sleep(2)
|
||||
driver.implicitly_wait(2)
|
||||
# --------------------To Turn on WIFi Switch if already OFF--------------------------------
|
||||
try:
|
||||
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
|
||||
try:
|
||||
if get_wifi_switch_element_text == "0" or get_wifi_switch_element_text == 0:
|
||||
get_wifi_switch_element = driver.find_element_by_xpath("//*[@label='Wi-Fi' and @value='0']")
|
||||
driver.implicitly_wait(1)
|
||||
get_wifi_switch_element.click()
|
||||
driver.implicitly_wait(1)
|
||||
i = 0
|
||||
for i in range(5):
|
||||
try:
|
||||
get_wifi_switch_element = driver.find_element_by_xpath("//*[@label='Wi-Fi' and @value='1']")
|
||||
get_wifi_switch_element_text = get_wifi_switch_element.text
|
||||
except:
|
||||
print("switch is OFF")
|
||||
|
||||
if get_wifi_switch_element_text == "1" or get_wifi_switch_element_text == 1:
|
||||
print("WIFI Switch is ON")
|
||||
break
|
||||
else:
|
||||
try:
|
||||
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):
|
||||
print("switch is still OFF")
|
||||
closeApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile)
|
||||
#return is_internet
|
||||
else:
|
||||
print("Switch is Still OFF")
|
||||
closeApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile)
|
||||
#return is_internet
|
||||
except:
|
||||
print("No switch element found")
|
||||
except:
|
||||
print("get_wifi_switch_element is ON")
|
||||
# --------------------To Turn on WIFi Switch if already OFF--------------------------------
|
||||
|
||||
except:
|
||||
print("Cannot find WIFI element")
|
||||
closeApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile)
|
||||
#return is_internet
|
||||
|
||||
# ---------------------This is to Forget current connected SSID-------------------------------
|
||||
|
||||
try:
|
||||
print("getting in to Additional details")
|
||||
additional_details_element = driver.find_element_by_xpath(
|
||||
"//*[@label='selected']/parent::*/parent::*/XCUIElementTypeButton[@label='More Info']")
|
||||
additional_details_element.click()
|
||||
try:
|
||||
print("Forget Connected Network")
|
||||
forget_ssid = driver.find_element_by_xpath("//*[@label='Forget This Network']")
|
||||
forget_ssid.click()
|
||||
print("Forget old ssid")
|
||||
try:
|
||||
report.step_start("Forget SSID popup1")
|
||||
forget_ssid_popup = driver.find_element_by_xpath("//*[@label='Forget']")
|
||||
forget_ssid_popup.click()
|
||||
|
||||
print("**alert** Forget SSID popup killed **alert**")
|
||||
except:
|
||||
print("Forget SSID popup not found")
|
||||
except:
|
||||
print("couldn't find forget ssid element")
|
||||
except:
|
||||
print("No connected SSID")
|
||||
|
||||
# ---------------------This is to Forget current connected SSID-------------------------------
|
||||
|
||||
# ---------------------To get all available SSID-------------------------------
|
||||
print("Searching for Wifi: " + WifiName)
|
||||
# allure.attach(name= body=str("Searching for Wifi: " + WifiName))
|
||||
time.sleep(2)
|
||||
print("Selecting Wifi: " + WifiName)
|
||||
ssid_found = False
|
||||
available_ssids = False
|
||||
|
||||
try:
|
||||
for check_for_all_ssids in range(2):
|
||||
available_ssids = get_all_available_ssids(driver)
|
||||
try:
|
||||
if WifiName not in available_ssids:
|
||||
scrollDown(setup_perfectoMobile)
|
||||
time.sleep(2)
|
||||
else:
|
||||
ssid_found = True
|
||||
print(WifiName + " : Found in Device")
|
||||
# allure.attach(name= body=str(WifiName + " : Found in Device"))
|
||||
break
|
||||
except:
|
||||
pass
|
||||
|
||||
if not ssid_found:
|
||||
print("could not found " + WifiName + " in device")
|
||||
closeApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile)
|
||||
return is_internet
|
||||
except:
|
||||
pass
|
||||
# ---------------------To get all available SSID-------------------------------
|
||||
|
||||
# ---------------------This is to Select SSID-------------------------------
|
||||
try:
|
||||
wifiSelectionElement = WebDriverWait(driver, 30).until(
|
||||
EC.presence_of_element_located((MobileBy.XPATH, "//*[@label='" + WifiName + "']")))
|
||||
wifiSelectionElement.click()
|
||||
print("Selecting SSID")
|
||||
except Exception as e:
|
||||
print("couldn't connect to " + WifiName)
|
||||
request.config.cache.set(key="SelectingWifiFailed", value=str(e))
|
||||
closeApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile)
|
||||
return is_internet
|
||||
# ---------------------This is to Select SSID-------------------------------
|
||||
|
||||
# ---------------------Set Password-------------------------------
|
||||
try:
|
||||
wifiPassword = driver.find_element_by_xpath("//*[@label='Password']")
|
||||
wifiPassword.send_keys(WifiPass)
|
||||
except NoSuchElementException:
|
||||
print("Enter Password Page Not Loaded")
|
||||
# ---------------------Set Password-------------------------------
|
||||
|
||||
# ---------------------Click on join-------------------------------
|
||||
try:
|
||||
joinBTN = driver.find_element_by_xpath("//*[@label='Join']")
|
||||
joinBTN.click()
|
||||
except Exception as e:
|
||||
print("Join Button Not Enabled...Password may not be needed")
|
||||
# ---------------------Click on join-------------------------------
|
||||
|
||||
try:
|
||||
time.sleep(4)
|
||||
driver.implicitly_wait(4)
|
||||
try:
|
||||
time.sleep(8)
|
||||
driver.implicitly_wait(2)
|
||||
print("Acceptiong terms and Services")
|
||||
report.step_start("loading Terms Page")
|
||||
element = driver.find_element_by_xpath("//*[@label='Accept Terms of Service']")
|
||||
element.click()
|
||||
except NoSuchElementException:
|
||||
print("Exception: Accept Terms of Service Button Not Found")
|
||||
reportFlag = False
|
||||
assert reportFlag
|
||||
try:
|
||||
time.sleep(2)
|
||||
driver.implicitly_wait(2)
|
||||
print("Continue to connect the services")
|
||||
report.step_start("Continiue Terms and Services Page")
|
||||
element = driver.find_element_by_xpath("//*[@label='Continue']")
|
||||
element.click()
|
||||
except NoSuchElementException:
|
||||
print("Exception: Continue to connect Terms of Service Button Not Found")
|
||||
try:
|
||||
time.sleep(2)
|
||||
driver.implicitly_wait(2)
|
||||
print("Continue to the services")
|
||||
report.step_start("Continue to use captive portal services")
|
||||
element = driver.find_element_by_xpath("//*[@label='Continue']")
|
||||
element.click()
|
||||
except NoSuchElementException:
|
||||
print("Exception: Continue to use captive portal services not found")
|
||||
try:
|
||||
time.sleep(2)
|
||||
driver.implicitly_wait(2)
|
||||
print("Final Result Page")
|
||||
report.step_start("Final Confirmation Page for Captive Portal Login")
|
||||
time.sleep(2)
|
||||
driver.implicitly_wait(2)
|
||||
element = driver.find_element_by_xpath("//*[@label='Done']")
|
||||
element.click()
|
||||
# if element == driver.find_element_by_xpath("//XCUIElementTypeOther[@label='Success']"):
|
||||
# element1 = driver.find_element_by_xpath("//*[@label='Done']")
|
||||
# element1.click()
|
||||
# else:
|
||||
# print("Failed to log in to captive portal")
|
||||
except NoSuchElementException:
|
||||
print("Exception: final Page for Captive Portal Not Found")
|
||||
|
||||
|
||||
except NoSuchElementException:
|
||||
print("No Splash Page Found")
|
||||
|
||||
|
||||
# ---------------------Additional INFO-------------------------------
|
||||
try:
|
||||
time.sleep(4)
|
||||
print("Selecting SSID: ",WifiName)
|
||||
report.step_start("Selecting SSID")
|
||||
additional_details_element = WebDriverWait(driver, 30).until(
|
||||
EC.presence_of_element_located((MobileBy.XPATH,
|
||||
"//*[@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
|
||||
print("ip_address_element_text: ", ip_address_element_text)
|
||||
# is_internet=True
|
||||
except Exception as e:
|
||||
print("IP Address not Found")
|
||||
request.config.cache.set(key="select IP failed", value=str(e))
|
||||
try:
|
||||
WifiInternetErrMsg2 = WebDriverWait(driver, 30).until(
|
||||
EC.presence_of_element_located((MobileBy.XPATH, "//*[@label='No Internet Connection']")))
|
||||
except Exception as e:
|
||||
is_internet = True
|
||||
print("No Wifi-AP Error Internet Error: " + WifiName)
|
||||
except Exception as e:
|
||||
request.config.cache.set(key="select additional info failed", value=str(e))
|
||||
# ---------------------Additional INFO-------------------------------
|
||||
|
||||
# --------------------- close app-------------------------------
|
||||
#closeApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile)
|
||||
return ip_address_element_text, is_internet
|
||||
|
||||
Reference in New Issue
Block a user