mirror of
https://github.com/Telecominfraproject/wlan-testing.git
synced 2025-11-02 11:57:49 +00:00
Wifi 7848 (#513)
* Updated the Client_reconnect library for Android Signed-off-by: haricharan-jaka <haricharan.jaka@candelatech.com> * Updated the Client_reconnect library for iOS Signed-off-by: haricharan-jaka <haricharan.jaka@candelatech.com> * Rectified the function name in testcase Signed-off-by: haricharan-jaka <haricharan.jaka@candelatech.com>
This commit is contained in:
@@ -5504,8 +5504,10 @@ def gets_ip_add_and_does_not_forget_ssid(request, WifiName, WifiPass, setup_perf
|
||||
check_if_no_internet_popup(driver)
|
||||
# -------------------------------------------------------
|
||||
|
||||
#Verify if WiFi is connected
|
||||
# Verify if WiFi is connected
|
||||
# -------------------------------------------------------
|
||||
if get_phone_information(setup_perfectoMobile=setup_perfectoMobile,
|
||||
search_this="osVersion") != "12":
|
||||
try:
|
||||
report.step_start("Verify if Wifi is Connected")
|
||||
WifiInternetErrMsg = WebDriverWait(driver, 35).until(
|
||||
@@ -5526,8 +5528,9 @@ def gets_ip_add_and_does_not_forget_ssid(request, WifiName, WifiPass, setup_perf
|
||||
check_if_no_internet_popup(driver)
|
||||
except:
|
||||
try:
|
||||
report.step_start("Verify if Wifi is Connected")
|
||||
WifiInternetErrMsg = WebDriverWait(driver, 60).until(EC.presence_of_element_located((
|
||||
report.step_start("Verify if Wifi is Connected - 2")
|
||||
WifiInternetErrMsg = WebDriverWait(driver, 60).until(
|
||||
EC.presence_of_element_located((
|
||||
MobileBy.XPATH,
|
||||
"//*[@resource-id='com.android.settings:id/summary' and @text='Connected']/parent::*/android.widget.TextView[@text='" + WifiName + "']")))
|
||||
ssid_with_internet = True
|
||||
@@ -5536,13 +5539,46 @@ def gets_ip_add_and_does_not_forget_ssid(request, WifiName, WifiPass, setup_perf
|
||||
print("Wifi Connection Error: " + WifiName)
|
||||
closeApp(connData["appPackage-android"], setup_perfectoMobile)
|
||||
return ip_address_element_text, ssid_with_internet
|
||||
else:
|
||||
try:
|
||||
report.step_start("Verifying wifi connection status connected/connected without internet")
|
||||
check_if_no_internet_popup(driver)
|
||||
check_if_no_internet_popup(driver)
|
||||
|
||||
wifi_connection_name = WebDriverWait(driver, 50).until(
|
||||
EC.presence_of_element_located((MobileBy.XPATH,
|
||||
"//*[@resource-id='com.android.settings:id/connected_list']/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.RelativeLayout[2]/android.widget.TextView[1]"
|
||||
)))
|
||||
if wifi_connection_name.text == WifiName:
|
||||
wifi_connection_status = WebDriverWait(driver, 50).until(
|
||||
EC.presence_of_element_located((MobileBy.XPATH,
|
||||
"//*[@resource-id='com.android.settings:id/summary']"
|
||||
)))
|
||||
if wifi_connection_status.text == "Connected":
|
||||
ssid_with_internet = True
|
||||
print("Connected with internet")
|
||||
|
||||
else:
|
||||
ssid_with_internet = False
|
||||
print("Wifi Successfully Connected without internet")
|
||||
check_if_no_internet_popup(driver)
|
||||
# Go into additional details here
|
||||
else:
|
||||
# Connected to some other wifi, makes sense to close app and fail this testcase
|
||||
closeApp(connData["appPackage-android"], setup_perfectoMobile)
|
||||
return ip_address_element_text, ssid_with_internet
|
||||
except:
|
||||
closeApp(connData["appPackage-android"], setup_perfectoMobile)
|
||||
return ip_address_element_text, ssid_with_internet
|
||||
# -------------------------------------------------------
|
||||
|
||||
#Get into Additional Details
|
||||
#To Get an IP Address
|
||||
#To Forget connection
|
||||
#To turn off auto. connect
|
||||
# Get into Additional Details
|
||||
# To Get an IP Address
|
||||
# To Forget connection
|
||||
# To turn off auto. connect
|
||||
# -------------------------------------------------------
|
||||
if get_phone_information(setup_perfectoMobile=setup_perfectoMobile,
|
||||
search_this="osVersion") != "12":
|
||||
try:
|
||||
print("Into additional details")
|
||||
time.sleep(2)
|
||||
@@ -5564,27 +5600,171 @@ def gets_ip_add_and_does_not_forget_ssid(request, WifiName, WifiPass, setup_perf
|
||||
print("Device IP address is :", ip_address_element_text)
|
||||
except:
|
||||
print("IP address element not found")
|
||||
#allure.attach(name= body=str("IP address element not found"))
|
||||
|
||||
# closeApp(connData["appPackage-android"], setup_perfectoMobile)
|
||||
# return ip_address_element_text, ssid_with_internet
|
||||
|
||||
closeApp(connData["appPackage-android"], setup_perfectoMobile)
|
||||
assert False
|
||||
# allure.attach(name= body=str("IP address element not found"))
|
||||
# --------------------Added for ssid security check--------------------------
|
||||
try:
|
||||
time.sleep(2)
|
||||
security_name_element = driver.find_element_by_xpath(
|
||||
"//*[@text='Security']/parent::*/android.widget.TextView[@resource-id='com.android.settings:id/summary']")
|
||||
security_name_element_text = security_name_element.text
|
||||
print("Ssid security is :", security_name_element_text)
|
||||
allure.attach(name="Ssid Security:", body=str(security_name_element_text))
|
||||
except:
|
||||
print("Security is not available")
|
||||
# --------------------Added for ssid Name check--------------------------
|
||||
try:
|
||||
time.sleep(2)
|
||||
ssid_name_element = driver.find_element_by_xpath(
|
||||
"//*[@resource-id='com.android.settings:id/entity_header_title']")
|
||||
ssid_name_element_text = ssid_name_element.text
|
||||
print("Ssid Name is :", ssid_name_element_text)
|
||||
allure.attach(name="Ssid connected:", body=str(ssid_name_element_text))
|
||||
except:
|
||||
print("Ssid name not available")
|
||||
closeApp(connData["appPackage-android"], setup_perfectoMobile)
|
||||
assert False
|
||||
if (ssid_name_element_text == WifiName):
|
||||
print("Wifi is connected to the expected ssid")
|
||||
else:
|
||||
print("Wifi is not connected to the expected ssid")
|
||||
closeApp(connData["appPackage-android"], setup_perfectoMobile)
|
||||
assert False
|
||||
try:
|
||||
check_if_no_internet_popup(driver)
|
||||
driver.implicitly_wait(3)
|
||||
time.sleep(2)
|
||||
auto_reconnect_off = driver.find("//*[@resource-id='android:id/switch_widget']")
|
||||
auto_reconnect_off_text = auto_reconnect_off.text
|
||||
if auto_reconnect_off_text != "On":
|
||||
if auto_reconnect_off_text != "Off":
|
||||
auto_reconnect_off.click()
|
||||
print("Auto reconnect turning on")
|
||||
print("Auto reconnect turning off")
|
||||
else:
|
||||
print("Auto reconnect is already on")
|
||||
print("Auto reconnect is already off")
|
||||
except:
|
||||
print("Couldn't find auto reconnect element")
|
||||
|
||||
# ------------------------------- Forget SSID ----------------
|
||||
try:
|
||||
check_if_no_internet_popup(driver)
|
||||
forget_ssid = driver.find_element_by_xpath(
|
||||
"//*[@resource-id='com.android.settings:id/forget_button']//*[@resource-id='com.android.settings:id/icon']")
|
||||
forget_ssid.click()
|
||||
print("Forgetting ssid")
|
||||
|
||||
# ------------------------------- Wifi Switch ----------------
|
||||
# try:
|
||||
# print("clicking on wifi switch")
|
||||
# get_switch_element = driver.find_element_by_xpath(
|
||||
# "//*[@resource-id='com.android.settings:id/switch_widget']")
|
||||
# driver.implicitly_wait(2)
|
||||
# get_switch_element.click()
|
||||
# except:
|
||||
# print("couldn't click on wifi switch")
|
||||
# #allure.attach(name= body=str("couldn't click on wifi switch"))
|
||||
except:
|
||||
print("Couldn't forget ssid")
|
||||
# closeApp(connData["appPackage-android"], setup_perfectoMobile)
|
||||
# return ip_address_element_text, ssid_with_internet
|
||||
except:
|
||||
print("Couldn't get into Additional settings")
|
||||
# -------------------------------------------------------
|
||||
else:
|
||||
try:
|
||||
print("Into additional details")
|
||||
time.sleep(2)
|
||||
additional_details_element = driver.find_element_by_xpath(
|
||||
"//*[@resource-id='com.android.settings:id/wifi_details']")
|
||||
additional_details_element.click()
|
||||
|
||||
try:
|
||||
print("click on view more")
|
||||
additional_details_element = WebDriverWait(driver, 50).until(
|
||||
EC.presence_of_element_located((MobileBy.XPATH, "//*[@text='View more']")))
|
||||
additional_details_element.click()
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
time.sleep(2)
|
||||
ssid_name_element = driver.find_element_by_xpath(
|
||||
"//*[@resource-id='com.android.settings:id/entity_header_title']")
|
||||
ssid_name_element_text = ssid_name_element.text
|
||||
print("Ssid Name is :", ssid_name_element_text)
|
||||
allure.attach(name="Ssid connected:", body=str(ssid_name_element_text))
|
||||
except:
|
||||
print("Ssid name not available")
|
||||
pass
|
||||
|
||||
if (ssid_name_element_text == WifiName):
|
||||
print("Wifi is connected to the expected ssid")
|
||||
ip_address_element_text = "SSID Match, S20 Does Not support scrolling"
|
||||
ssid_with_internet = "SSID Match, S20 Does Not support scrolling"
|
||||
# return ip_address_element_text, ssid_with_internet
|
||||
else:
|
||||
print("Wifi is not connected to the expected ssid")
|
||||
closeApp(connData["appPackage-android"], setup_perfectoMobile)
|
||||
|
||||
report.step_start("Scrolling for ip address - 1")
|
||||
# if deviceModelName == "Galaxy S20":
|
||||
# print("Scrolling for S20")
|
||||
driver.swipe(470, 1400, 470, 1000, 400)
|
||||
# else:
|
||||
# scrollDown(setup_perfectoMobile)
|
||||
|
||||
report.step_start("Scrolling for ip address - 2")
|
||||
# if deviceModelName == "Galaxy S20":
|
||||
# print("Scrolling for S20")
|
||||
driver.swipe(470, 1400, 470, 1000, 400)
|
||||
# else:
|
||||
# scrollDown(setup_perfectoMobile)
|
||||
|
||||
report.step_start("Scrolling for ip address - 3")
|
||||
# if deviceModelName == "Galaxy S20":
|
||||
# print("Scrolling for S20")
|
||||
driver.swipe(470, 1400, 470, 1000, 400)
|
||||
# else:
|
||||
# scrollDown(setup_perfectoMobile)
|
||||
report.step_start("looking for ip address")
|
||||
|
||||
try:
|
||||
ip_address_element_text = driver.find_element_by_xpath(
|
||||
"//*[@resource-id='com.android.settings:id/recycler_view']/android.widget.LinearLayout[4]/android.widget.RelativeLayout[1]/android.widget.TextView[2]")
|
||||
ip_address_element_text = ip_address_element_text.text
|
||||
ssid_with_internet = True
|
||||
except:
|
||||
print("Unable to get IP address")
|
||||
pass
|
||||
|
||||
# report.step_start("Forget SSID")
|
||||
#
|
||||
# try:
|
||||
# check_if_no_internet_popup(driver)
|
||||
# forget_ssid = driver.find_element_by_xpath(
|
||||
# "//*[@text='Forget']")
|
||||
# forget_ssid.click()
|
||||
# print("Forgetting ssid")
|
||||
#
|
||||
# # ------------------------------- Wifi Switch ----------------
|
||||
# # try:
|
||||
# # print("clicking on wifi switch")
|
||||
# # get_switch_element = driver.find_element_by_xpath(
|
||||
# # "//*[@resource-id='com.android.settings:id/switch_widget']")
|
||||
# # driver.implicitly_wait(2)
|
||||
# # get_switch_element.click()
|
||||
# # except:
|
||||
# # print("couldn't click on wifi switch")
|
||||
# # #allure.attach(name= body=str("couldn't click on wifi switch"))
|
||||
# except:
|
||||
# print("Couldn't forget ssid")
|
||||
# closeApp(connData["appPackage-android"], setup_perfectoMobile)
|
||||
# return ip_address_element_text, ssid_with_internet
|
||||
except:
|
||||
print("Couldn't get into Additional settings")
|
||||
# -------------------------------------------------------
|
||||
|
||||
# -------------------------------------------------------
|
||||
except:
|
||||
print("No Switch element found")
|
||||
# ---------------------To Turn on WIFi Switch if already OFF-------------------------------
|
||||
@@ -5595,7 +5775,6 @@ def gets_ip_add_and_does_not_forget_ssid(request, WifiName, WifiPass, setup_perf
|
||||
|
||||
except:
|
||||
print("Exception: Verify Xpath - Update/check Xpath for Click Connections")
|
||||
# -----------------To Open Connections page---------------------------
|
||||
#--------------------Pixel 4 code---------------------------
|
||||
else:
|
||||
report.step_start("Set Wifi Network to " + WifiName)
|
||||
@@ -6122,8 +6301,10 @@ def gets_ip_add_eap_and_does_not_forget_ssid(request, WifiName, User, ttls_passw
|
||||
check_if_no_internet_popup(driver)
|
||||
# -------------------------------------------------------
|
||||
|
||||
#Verify if WiFi is connected
|
||||
# Verify if WiFi is connected
|
||||
# -------------------------------------------------------
|
||||
if get_phone_information(setup_perfectoMobile=setup_perfectoMobile,
|
||||
search_this="osVersion") != "12":
|
||||
try:
|
||||
report.step_start("Verify if Wifi is Connected")
|
||||
WifiInternetErrMsg = WebDriverWait(driver, 35).until(
|
||||
@@ -6144,8 +6325,9 @@ def gets_ip_add_eap_and_does_not_forget_ssid(request, WifiName, User, ttls_passw
|
||||
check_if_no_internet_popup(driver)
|
||||
except:
|
||||
try:
|
||||
report.step_start("Verify if Wifi is Connected")
|
||||
WifiInternetErrMsg = WebDriverWait(driver, 60).until(EC.presence_of_element_located((
|
||||
report.step_start("Verify if Wifi is Connected - 2")
|
||||
WifiInternetErrMsg = WebDriverWait(driver, 60).until(
|
||||
EC.presence_of_element_located((
|
||||
MobileBy.XPATH,
|
||||
"//*[@resource-id='com.android.settings:id/summary' and @text='Connected']/parent::*/android.widget.TextView[@text='" + WifiName + "']")))
|
||||
ssid_with_internet = True
|
||||
@@ -6154,13 +6336,46 @@ def gets_ip_add_eap_and_does_not_forget_ssid(request, WifiName, User, ttls_passw
|
||||
print("Wifi Connection Error: " + WifiName)
|
||||
closeApp(connData["appPackage-android"], setup_perfectoMobile)
|
||||
return ip_address_element_text, ssid_with_internet
|
||||
else:
|
||||
try:
|
||||
report.step_start("Verifying wifi connection status connected/connected without internet")
|
||||
check_if_no_internet_popup(driver)
|
||||
check_if_no_internet_popup(driver)
|
||||
|
||||
wifi_connection_name = WebDriverWait(driver, 50).until(
|
||||
EC.presence_of_element_located((MobileBy.XPATH,
|
||||
"//*[@resource-id='com.android.settings:id/connected_list']/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.RelativeLayout[2]/android.widget.TextView[1]"
|
||||
)))
|
||||
if wifi_connection_name.text == WifiName:
|
||||
wifi_connection_status = WebDriverWait(driver, 50).until(
|
||||
EC.presence_of_element_located((MobileBy.XPATH,
|
||||
"//*[@resource-id='com.android.settings:id/summary']"
|
||||
)))
|
||||
if wifi_connection_status.text == "Connected":
|
||||
ssid_with_internet = True
|
||||
print("Connected with internet")
|
||||
|
||||
else:
|
||||
ssid_with_internet = False
|
||||
print("Wifi Successfully Connected without internet")
|
||||
check_if_no_internet_popup(driver)
|
||||
# Go into additional details here
|
||||
else:
|
||||
# Connected to some other wifi, makes sense to close app and fail this testcase
|
||||
closeApp(connData["appPackage-android"], setup_perfectoMobile)
|
||||
return ip_address_element_text, ssid_with_internet
|
||||
except:
|
||||
closeApp(connData["appPackage-android"], setup_perfectoMobile)
|
||||
return ip_address_element_text, ssid_with_internet
|
||||
# -------------------------------------------------------
|
||||
|
||||
#Get into Additional Details
|
||||
#To Get an IP Address
|
||||
#To Forget connection
|
||||
#To turn off auto. connect
|
||||
# Get into Additional Details
|
||||
# To Get an IP Address
|
||||
# To Forget connection
|
||||
# To turn off auto. connect
|
||||
# -------------------------------------------------------
|
||||
if get_phone_information(setup_perfectoMobile=setup_perfectoMobile,
|
||||
search_this="osVersion") != "12":
|
||||
try:
|
||||
print("Into additional details")
|
||||
time.sleep(2)
|
||||
@@ -6182,27 +6397,171 @@ def gets_ip_add_eap_and_does_not_forget_ssid(request, WifiName, User, ttls_passw
|
||||
print("Device IP address is :", ip_address_element_text)
|
||||
except:
|
||||
print("IP address element not found")
|
||||
#allure.attach(name= body=str("IP address element not found"))
|
||||
|
||||
# closeApp(connData["appPackage-android"], setup_perfectoMobile)
|
||||
# return ip_address_element_text, ssid_with_internet
|
||||
|
||||
closeApp(connData["appPackage-android"], setup_perfectoMobile)
|
||||
assert False
|
||||
# allure.attach(name= body=str("IP address element not found"))
|
||||
# --------------------Added for ssid security check--------------------------
|
||||
try:
|
||||
time.sleep(2)
|
||||
security_name_element = driver.find_element_by_xpath(
|
||||
"//*[@text='Security']/parent::*/android.widget.TextView[@resource-id='com.android.settings:id/summary']")
|
||||
security_name_element_text = security_name_element.text
|
||||
print("Ssid security is :", security_name_element_text)
|
||||
allure.attach(name="Ssid Security:", body=str(security_name_element_text))
|
||||
except:
|
||||
print("Security is not available")
|
||||
# --------------------Added for ssid Name check--------------------------
|
||||
try:
|
||||
time.sleep(2)
|
||||
ssid_name_element = driver.find_element_by_xpath(
|
||||
"//*[@resource-id='com.android.settings:id/entity_header_title']")
|
||||
ssid_name_element_text = ssid_name_element.text
|
||||
print("Ssid Name is :", ssid_name_element_text)
|
||||
allure.attach(name="Ssid connected:", body=str(ssid_name_element_text))
|
||||
except:
|
||||
print("Ssid name not available")
|
||||
closeApp(connData["appPackage-android"], setup_perfectoMobile)
|
||||
assert False
|
||||
if (ssid_name_element_text == WifiName):
|
||||
print("Wifi is connected to the expected ssid")
|
||||
else:
|
||||
print("Wifi is not connected to the expected ssid")
|
||||
closeApp(connData["appPackage-android"], setup_perfectoMobile)
|
||||
assert False
|
||||
try:
|
||||
check_if_no_internet_popup(driver)
|
||||
driver.implicitly_wait(3)
|
||||
time.sleep(2)
|
||||
auto_reconnect_off = driver.find("//*[@resource-id='android:id/switch_widget']")
|
||||
auto_reconnect_off_text = auto_reconnect_off.text
|
||||
if auto_reconnect_off_text != "On":
|
||||
if auto_reconnect_off_text != "Off":
|
||||
auto_reconnect_off.click()
|
||||
print("Auto reconnect turning on")
|
||||
print("Auto reconnect turning off")
|
||||
else:
|
||||
print("Auto reconnect is already on")
|
||||
print("Auto reconnect is already off")
|
||||
except:
|
||||
print("Couldn't find auto reconnect element")
|
||||
|
||||
# ------------------------------- Forget SSID ----------------
|
||||
try:
|
||||
check_if_no_internet_popup(driver)
|
||||
forget_ssid = driver.find_element_by_xpath(
|
||||
"//*[@resource-id='com.android.settings:id/forget_button']//*[@resource-id='com.android.settings:id/icon']")
|
||||
forget_ssid.click()
|
||||
print("Forgetting ssid")
|
||||
|
||||
# ------------------------------- Wifi Switch ----------------
|
||||
# try:
|
||||
# print("clicking on wifi switch")
|
||||
# get_switch_element = driver.find_element_by_xpath(
|
||||
# "//*[@resource-id='com.android.settings:id/switch_widget']")
|
||||
# driver.implicitly_wait(2)
|
||||
# get_switch_element.click()
|
||||
# except:
|
||||
# print("couldn't click on wifi switch")
|
||||
# #allure.attach(name= body=str("couldn't click on wifi switch"))
|
||||
except:
|
||||
print("Couldn't forget ssid")
|
||||
# closeApp(connData["appPackage-android"], setup_perfectoMobile)
|
||||
# return ip_address_element_text, ssid_with_internet
|
||||
except:
|
||||
print("Couldn't get into Additional settings")
|
||||
# -------------------------------------------------------
|
||||
else:
|
||||
try:
|
||||
print("Into additional details")
|
||||
time.sleep(2)
|
||||
additional_details_element = driver.find_element_by_xpath(
|
||||
"//*[@resource-id='com.android.settings:id/wifi_details']")
|
||||
additional_details_element.click()
|
||||
|
||||
try:
|
||||
print("click on view more")
|
||||
additional_details_element = WebDriverWait(driver, 50).until(
|
||||
EC.presence_of_element_located((MobileBy.XPATH, "//*[@text='View more']")))
|
||||
additional_details_element.click()
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
time.sleep(2)
|
||||
ssid_name_element = driver.find_element_by_xpath(
|
||||
"//*[@resource-id='com.android.settings:id/entity_header_title']")
|
||||
ssid_name_element_text = ssid_name_element.text
|
||||
print("Ssid Name is :", ssid_name_element_text)
|
||||
allure.attach(name="Ssid connected:", body=str(ssid_name_element_text))
|
||||
except:
|
||||
print("Ssid name not available")
|
||||
pass
|
||||
|
||||
if (ssid_name_element_text == WifiName):
|
||||
print("Wifi is connected to the expected ssid")
|
||||
ip_address_element_text = "SSID Match, S20 Does Not support scrolling"
|
||||
ssid_with_internet = "SSID Match, S20 Does Not support scrolling"
|
||||
# return ip_address_element_text, ssid_with_internet
|
||||
else:
|
||||
print("Wifi is not connected to the expected ssid")
|
||||
closeApp(connData["appPackage-android"], setup_perfectoMobile)
|
||||
|
||||
report.step_start("Scrolling for ip address - 1")
|
||||
# if deviceModelName == "Galaxy S20":
|
||||
# print("Scrolling for S20")
|
||||
driver.swipe(470, 1400, 470, 1000, 400)
|
||||
# else:
|
||||
# scrollDown(setup_perfectoMobile)
|
||||
|
||||
report.step_start("Scrolling for ip address - 2")
|
||||
# if deviceModelName == "Galaxy S20":
|
||||
# print("Scrolling for S20")
|
||||
driver.swipe(470, 1400, 470, 1000, 400)
|
||||
# else:
|
||||
# scrollDown(setup_perfectoMobile)
|
||||
|
||||
report.step_start("Scrolling for ip address - 3")
|
||||
# if deviceModelName == "Galaxy S20":
|
||||
# print("Scrolling for S20")
|
||||
driver.swipe(470, 1400, 470, 1000, 400)
|
||||
# else:
|
||||
# scrollDown(setup_perfectoMobile)
|
||||
report.step_start("looking for ip address")
|
||||
|
||||
try:
|
||||
ip_address_element_text = driver.find_element_by_xpath(
|
||||
"//*[@resource-id='com.android.settings:id/recycler_view']/android.widget.LinearLayout[4]/android.widget.RelativeLayout[1]/android.widget.TextView[2]")
|
||||
ip_address_element_text = ip_address_element_text.text
|
||||
ssid_with_internet = True
|
||||
except:
|
||||
print("Unable to get IP address")
|
||||
pass
|
||||
|
||||
# report.step_start("Forget SSID")
|
||||
#
|
||||
# try:
|
||||
# check_if_no_internet_popup(driver)
|
||||
# forget_ssid = driver.find_element_by_xpath(
|
||||
# "//*[@text='Forget']")
|
||||
# forget_ssid.click()
|
||||
# print("Forgetting ssid")
|
||||
#
|
||||
# # ------------------------------- Wifi Switch ----------------
|
||||
# # try:
|
||||
# # print("clicking on wifi switch")
|
||||
# # get_switch_element = driver.find_element_by_xpath(
|
||||
# # "//*[@resource-id='com.android.settings:id/switch_widget']")
|
||||
# # driver.implicitly_wait(2)
|
||||
# # get_switch_element.click()
|
||||
# # except:
|
||||
# # print("couldn't click on wifi switch")
|
||||
# # #allure.attach(name= body=str("couldn't click on wifi switch"))
|
||||
# except:
|
||||
# print("Couldn't forget ssid")
|
||||
# closeApp(connData["appPackage-android"], setup_perfectoMobile)
|
||||
# return ip_address_element_text, ssid_with_internet
|
||||
except:
|
||||
print("Couldn't get into Additional settings")
|
||||
# -------------------------------------------------------
|
||||
|
||||
# -------------------------------------------------------
|
||||
except:
|
||||
print("No Switch element found")
|
||||
# ---------------------To Turn on WIFi Switch if already OFF-------------------------------
|
||||
@@ -6213,7 +6572,6 @@ def gets_ip_add_eap_and_does_not_forget_ssid(request, WifiName, User, ttls_passw
|
||||
|
||||
except:
|
||||
print("Exception: Verify Xpath - Update/check Xpath for Click Connections")
|
||||
# -----------------To Open Connections page---------------------------
|
||||
else: #--------------------Pixel code-----------------------------------
|
||||
report.step_start("Set Wifi Network to " + WifiName)
|
||||
|
||||
@@ -6637,6 +6995,10 @@ def gets_ip_add_for_checking_and_forgets_ssid(request, WifiName, WifiPass, setup
|
||||
closeApp(connData["appPackage-android"], setup_perfectoMobile)
|
||||
return ip_address_element_text, ssid_with_internet
|
||||
# -------------------------------------------------------
|
||||
# Verify if WiFi is connected
|
||||
# -------------------------------------------------------
|
||||
if get_phone_information(setup_perfectoMobile=setup_perfectoMobile,
|
||||
search_this="osVersion") != "12":
|
||||
try:
|
||||
report.step_start("Verify if Wifi is Connected")
|
||||
WifiInternetErrMsg = WebDriverWait(driver, 35).until(
|
||||
@@ -6657,8 +7019,9 @@ def gets_ip_add_for_checking_and_forgets_ssid(request, WifiName, WifiPass, setup
|
||||
check_if_no_internet_popup(driver)
|
||||
except:
|
||||
try:
|
||||
report.step_start("Verify if Wifi is Connected")
|
||||
WifiInternetErrMsg = WebDriverWait(driver, 60).until(EC.presence_of_element_located((
|
||||
report.step_start("Verify if Wifi is Connected - 2")
|
||||
WifiInternetErrMsg = WebDriverWait(driver, 60).until(
|
||||
EC.presence_of_element_located((
|
||||
MobileBy.XPATH,
|
||||
"//*[@resource-id='com.android.settings:id/summary' and @text='Connected']/parent::*/android.widget.TextView[@text='" + WifiName + "']")))
|
||||
ssid_with_internet = True
|
||||
@@ -6667,13 +7030,47 @@ def gets_ip_add_for_checking_and_forgets_ssid(request, WifiName, WifiPass, setup
|
||||
print("Wifi Connection Error: " + WifiName)
|
||||
closeApp(connData["appPackage-android"], setup_perfectoMobile)
|
||||
return ip_address_element_text, ssid_with_internet
|
||||
else:
|
||||
try:
|
||||
report.step_start(
|
||||
"Verifying wifi connection status connected/connected without internet")
|
||||
check_if_no_internet_popup(driver)
|
||||
check_if_no_internet_popup(driver)
|
||||
|
||||
wifi_connection_name = WebDriverWait(driver, 50).until(
|
||||
EC.presence_of_element_located((MobileBy.XPATH,
|
||||
"//*[@resource-id='com.android.settings:id/connected_list']/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.RelativeLayout[2]/android.widget.TextView[1]"
|
||||
)))
|
||||
if wifi_connection_name.text == WifiName:
|
||||
wifi_connection_status = WebDriverWait(driver, 50).until(
|
||||
EC.presence_of_element_located((MobileBy.XPATH,
|
||||
"//*[@resource-id='com.android.settings:id/summary']"
|
||||
)))
|
||||
if wifi_connection_status.text == "Connected":
|
||||
ssid_with_internet = True
|
||||
print("Connected with internet")
|
||||
|
||||
else:
|
||||
ssid_with_internet = False
|
||||
print("Wifi Successfully Connected without internet")
|
||||
check_if_no_internet_popup(driver)
|
||||
# Go into additional details here
|
||||
else:
|
||||
# Connected to some other wifi, makes sense to close app and fail this testcase
|
||||
closeApp(connData["appPackage-android"], setup_perfectoMobile)
|
||||
return ip_address_element_text, ssid_with_internet
|
||||
except:
|
||||
closeApp(connData["appPackage-android"], setup_perfectoMobile)
|
||||
return ip_address_element_text, ssid_with_internet
|
||||
# -------------------------------------------------------
|
||||
|
||||
#Get into Additional Details
|
||||
#To Get an IP Address
|
||||
#To Forget connection
|
||||
#To turn off auto. connect
|
||||
# Get into Additional Details
|
||||
# To Get an IP Address
|
||||
# To Forget connection
|
||||
# To turn off auto. connect
|
||||
# -------------------------------------------------------
|
||||
if get_phone_information(setup_perfectoMobile=setup_perfectoMobile,
|
||||
search_this="osVersion") != "12":
|
||||
try:
|
||||
print("Into additional details")
|
||||
time.sleep(2)
|
||||
@@ -6695,11 +7092,37 @@ def gets_ip_add_for_checking_and_forgets_ssid(request, WifiName, WifiPass, setup
|
||||
print("Device IP address is :", ip_address_element_text)
|
||||
except:
|
||||
print("IP address element not found")
|
||||
#allure.attach(name= body=str("IP address element not found"))
|
||||
|
||||
# closeApp(connData["appPackage-android"], setup_perfectoMobile)
|
||||
# return ip_address_element_text, ssid_with_internet
|
||||
|
||||
closeApp(connData["appPackage-android"], setup_perfectoMobile)
|
||||
assert False
|
||||
# allure.attach(name= body=str("IP address element not found"))
|
||||
# --------------------Added for ssid security check--------------------------
|
||||
try:
|
||||
time.sleep(2)
|
||||
security_name_element = driver.find_element_by_xpath(
|
||||
"//*[@text='Security']/parent::*/android.widget.TextView[@resource-id='com.android.settings:id/summary']")
|
||||
security_name_element_text = security_name_element.text
|
||||
print("Ssid security is :", security_name_element_text)
|
||||
allure.attach(name="Ssid Security:", body=str(security_name_element_text))
|
||||
except:
|
||||
print("Security is not available")
|
||||
# --------------------Added for ssid Name check--------------------------
|
||||
try:
|
||||
time.sleep(2)
|
||||
ssid_name_element = driver.find_element_by_xpath(
|
||||
"//*[@resource-id='com.android.settings:id/entity_header_title']")
|
||||
ssid_name_element_text = ssid_name_element.text
|
||||
print("Ssid Name is :", ssid_name_element_text)
|
||||
allure.attach(name="Ssid connected:", body=str(ssid_name_element_text))
|
||||
except:
|
||||
print("Ssid name not available")
|
||||
closeApp(connData["appPackage-android"], setup_perfectoMobile)
|
||||
assert False
|
||||
if (ssid_name_element_text == WifiName):
|
||||
print("Wifi is connected to the expected ssid")
|
||||
else:
|
||||
print("Wifi is not connected to the expected ssid")
|
||||
closeApp(connData["appPackage-android"], setup_perfectoMobile)
|
||||
assert False
|
||||
try:
|
||||
check_if_no_internet_popup(driver)
|
||||
driver.implicitly_wait(3)
|
||||
@@ -6722,7 +7145,7 @@ def gets_ip_add_for_checking_and_forgets_ssid(request, WifiName, WifiPass, setup
|
||||
forget_ssid.click()
|
||||
print("Forgetting ssid")
|
||||
|
||||
#------------------------------- Wifi Switch ----------------
|
||||
# ------------------------------- Wifi Switch ----------------
|
||||
# try:
|
||||
# print("clicking on wifi switch")
|
||||
# get_switch_element = driver.find_element_by_xpath(
|
||||
@@ -6739,17 +7162,108 @@ def gets_ip_add_for_checking_and_forgets_ssid(request, WifiName, WifiPass, setup
|
||||
except:
|
||||
print("Couldn't get into Additional settings")
|
||||
# -------------------------------------------------------
|
||||
else:
|
||||
try:
|
||||
print("Into additional details")
|
||||
time.sleep(2)
|
||||
additional_details_element = driver.find_element_by_xpath(
|
||||
"//*[@resource-id='com.android.settings:id/wifi_details']")
|
||||
additional_details_element.click()
|
||||
|
||||
try:
|
||||
print("click on view more")
|
||||
additional_details_element = WebDriverWait(driver, 50).until(
|
||||
EC.presence_of_element_located((MobileBy.XPATH, "//*[@text='View more']")))
|
||||
additional_details_element.click()
|
||||
except:
|
||||
print("No Switch element found")
|
||||
# ---------------------To Turn on WIFi Switch if already OFF-------------------------------
|
||||
pass
|
||||
|
||||
try:
|
||||
time.sleep(2)
|
||||
ssid_name_element = driver.find_element_by_xpath(
|
||||
"//*[@resource-id='com.android.settings:id/entity_header_title']")
|
||||
ssid_name_element_text = ssid_name_element.text
|
||||
print("Ssid Name is :", ssid_name_element_text)
|
||||
allure.attach(name="Ssid connected:", body=str(ssid_name_element_text))
|
||||
except:
|
||||
print("Ssid name not available")
|
||||
pass
|
||||
|
||||
if (ssid_name_element_text == WifiName):
|
||||
print("Wifi is connected to the expected ssid")
|
||||
ip_address_element_text = "SSID Match, S20 Does Not support scrolling"
|
||||
ssid_with_internet = "SSID Match, S20 Does Not support scrolling"
|
||||
# return ip_address_element_text, ssid_with_internet
|
||||
else:
|
||||
print("Wifi is not connected to the expected ssid")
|
||||
closeApp(connData["appPackage-android"], setup_perfectoMobile)
|
||||
|
||||
report.step_start("Scrolling for ip address - 1")
|
||||
# if deviceModelName == "Galaxy S20":
|
||||
# print("Scrolling for S20")
|
||||
driver.swipe(470, 1400, 470, 1000, 400)
|
||||
# else:
|
||||
# scrollDown(setup_perfectoMobile)
|
||||
|
||||
report.step_start("Scrolling for ip address - 2")
|
||||
# if deviceModelName == "Galaxy S20":
|
||||
# print("Scrolling for S20")
|
||||
driver.swipe(470, 1400, 470, 1000, 400)
|
||||
# else:
|
||||
# scrollDown(setup_perfectoMobile)
|
||||
|
||||
report.step_start("Scrolling for ip address - 3")
|
||||
# if deviceModelName == "Galaxy S20":
|
||||
# print("Scrolling for S20")
|
||||
driver.swipe(470, 1400, 470, 1000, 400)
|
||||
# else:
|
||||
# scrollDown(setup_perfectoMobile)
|
||||
report.step_start("looking for ip address")
|
||||
|
||||
try:
|
||||
ip_address_element_text = driver.find_element_by_xpath(
|
||||
"//*[@resource-id='com.android.settings:id/recycler_view']/android.widget.LinearLayout[4]/android.widget.RelativeLayout[1]/android.widget.TextView[2]")
|
||||
ip_address_element_text = ip_address_element_text.text
|
||||
ssid_with_internet = True
|
||||
except:
|
||||
print("Unable to get IP address")
|
||||
pass
|
||||
|
||||
report.step_start("Forget SSID")
|
||||
|
||||
try:
|
||||
check_if_no_internet_popup(driver)
|
||||
forget_ssid = driver.find_element_by_xpath(
|
||||
"//*[@text='Forget']")
|
||||
forget_ssid.click()
|
||||
print("Forgetting ssid")
|
||||
|
||||
# ------------------------------- Wifi Switch ----------------
|
||||
# try:
|
||||
# print("clicking on wifi switch")
|
||||
# get_switch_element = driver.find_element_by_xpath(
|
||||
# "//*[@resource-id='com.android.settings:id/switch_widget']")
|
||||
# driver.implicitly_wait(2)
|
||||
# get_switch_element.click()
|
||||
# except:
|
||||
# print("couldn't click on wifi switch")
|
||||
# #allure.attach(name= body=str("couldn't click on wifi switch"))
|
||||
except:
|
||||
print("Couldn't forget ssid")
|
||||
closeApp(connData["appPackage-android"], setup_perfectoMobile)
|
||||
return ip_address_element_text, ssid_with_internet
|
||||
except:
|
||||
print("Couldn't get into Additional settings")
|
||||
# -------------------------------------------------------
|
||||
|
||||
except:
|
||||
print("Couldn't find wifi Button")
|
||||
# ------------------Open WIFI page----------------------------------
|
||||
|
||||
except:
|
||||
print("No Switch element found")
|
||||
# ---------------------To Turn on WIFi Switch if already OFF-------------------------------
|
||||
except:
|
||||
print("Exception: Verify Xpath - Update/check Xpath for Click Connections")
|
||||
# -----------------To Open Connections page---------------------------
|
||||
#--------------------Pixel 4 code---------------------------
|
||||
else:
|
||||
report.step_start("Set Wifi Network to " + WifiName)
|
||||
|
||||
@@ -2690,22 +2690,30 @@ def gets_ip_add_and_does_not_forget_ssid_ios(request, WifiName, WifiPass, setup_
|
||||
available_ssids = get_all_available_ssids(driver)
|
||||
allure.attach(name="Available SSIDs in device: ", body=str(available_ssids))
|
||||
try:
|
||||
if WifiName not in available_ssids:
|
||||
if (not ssid_Visible(driver, WifiName)) or (WifiName not in available_ssids):
|
||||
scrollDown(setup_perfectoMobile)
|
||||
time.sleep(2)
|
||||
else:
|
||||
try:
|
||||
driver.implicitly_wait(8)
|
||||
report.step_start("Selecting SSID To Connect")
|
||||
ssid_found = True
|
||||
print(WifiName + " : Found in Device")
|
||||
wifiSelElement = WebDriverWait(driver, 30).until(EC.presence_of_element_located((MobileBy.XPATH, "//*[@label='" + WifiName + "']")))
|
||||
wifiSelElement = WebDriverWait(driver, 35).until(
|
||||
EC.presence_of_element_located((MobileBy.XPATH, "//*[@label='" + WifiName + "']")))
|
||||
print(wifiSelElement)
|
||||
wifiSelElement.click()
|
||||
print("Selecting SSID")
|
||||
# allure.attach(name= body=str(WifiName + " : Found in Device"))
|
||||
break
|
||||
except:
|
||||
print("SSID unable to select")
|
||||
report.step_start("Selecting Unable SSID To Connect")
|
||||
closeApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile)
|
||||
return ip_address_element_text, is_internet
|
||||
|
||||
except:
|
||||
print("couldn't connect to " + WifiName)
|
||||
#request.config.cache.set(key="SelectingWifiFailed", value=str(e))
|
||||
# request.config.cache.set(key="SelectingWifiFailed", value=str(e))
|
||||
closeApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile)
|
||||
return ip_address_element_text, is_internet
|
||||
pass
|
||||
@@ -2792,6 +2800,7 @@ def gets_ip_add_and_does_not_forget_ssid_ios(request, WifiName, WifiPass, setup_
|
||||
except Exception as e:
|
||||
print("WiFi-Address not Found")
|
||||
try:
|
||||
time.sleep(4)
|
||||
report.step_start("Checking IP Address")
|
||||
print("Checking IP address")
|
||||
# (//*[@label="IP Address"]/parent::*/XCUIElementTypeStaticText)[2]
|
||||
@@ -2799,6 +2808,14 @@ def gets_ip_add_and_does_not_forget_ssid_ios(request, WifiName, WifiPass, setup_
|
||||
"(//*[@label='IP Address']/parent::*/XCUIElementTypeStaticText)[2]").text
|
||||
print("ip_address_element_text: ", ip_address_element_text)
|
||||
except Exception as e:
|
||||
try:
|
||||
time.sleep(4)
|
||||
print("Scrolling for checking ip address")
|
||||
scrollDown(setup_perfectoMobile)
|
||||
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:
|
||||
print("IP Address not Found")
|
||||
request.config.cache.set(key="select IP failed", value=str(e))
|
||||
|
||||
@@ -2935,20 +2952,26 @@ def gets_ip_add_eap_and_does_not_forget_ssid_ios(request, WifiName, User, ttls_p
|
||||
available_ssids = get_all_available_ssids(driver)
|
||||
allure.attach(name="Available SSIDs in device: ", body=str(available_ssids))
|
||||
try:
|
||||
if WifiName not in available_ssids:
|
||||
if (not ssid_Visible(driver, WifiName)) or (WifiName not in available_ssids):
|
||||
scrollDown(setup_perfectoMobile)
|
||||
time.sleep(2)
|
||||
else:
|
||||
try:
|
||||
driver.implicitly_wait(8)
|
||||
report.step_start("Selecting SSID To Connect")
|
||||
ssid_found = True
|
||||
print(WifiName + " : Found in Device")
|
||||
wifiSelElement = WebDriverWait(driver, 30).until(
|
||||
wifiSelElement = WebDriverWait(driver, 35).until(
|
||||
EC.presence_of_element_located((MobileBy.XPATH, "//*[@label='" + WifiName + "']")))
|
||||
print(wifiSelElement)
|
||||
wifiSelElement.click()
|
||||
print("Selecting SSID")
|
||||
# allure.attach(name= body=str(WifiName + " : Found in Device"))
|
||||
break
|
||||
except:
|
||||
print("SSID unable to select")
|
||||
report.step_start("Selecting Unable SSID To Connect")
|
||||
closeApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile)
|
||||
return ip_address_element_text, is_internet
|
||||
except:
|
||||
print("couldn't connect to " + WifiName)
|
||||
# request.config.cache.set(key="SelectingWifiFailed", value=str(e))
|
||||
@@ -3058,15 +3081,22 @@ def gets_ip_add_eap_and_does_not_forget_ssid_ios(request, WifiName, User, ttls_p
|
||||
print("WiFi-Address not Found")
|
||||
allure.attach(name="No Connected SSID WiFi-Address Found")
|
||||
try:
|
||||
driver.implicitly_wait(5)
|
||||
print("Checking IP address")
|
||||
report.step_start("Checking IP address")
|
||||
time.sleep(4)
|
||||
report.step_start("Checking IP Address")
|
||||
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)
|
||||
except Exception as e:
|
||||
try:
|
||||
time.sleep(4)
|
||||
print("Scrolling for checking ip address")
|
||||
scrollDown(setup_perfectoMobile)
|
||||
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:
|
||||
print("IP Address not Found")
|
||||
request.config.cache.set(key="select IP failed", value=str(e))
|
||||
|
||||
@@ -3201,6 +3231,7 @@ def gets_ip_add_for_checking_and_forgets_ssid_ios(request, WifiName, WifiPass, s
|
||||
except Exception as e:
|
||||
print("WiFi-Address not Found")
|
||||
try:
|
||||
time.sleep(4)
|
||||
report.step_start("Checking IP Address")
|
||||
print("Checking IP address")
|
||||
# (//*[@label="IP Address"]/parent::*/XCUIElementTypeStaticText)[2]
|
||||
@@ -3208,9 +3239,16 @@ def gets_ip_add_for_checking_and_forgets_ssid_ios(request, WifiName, WifiPass, s
|
||||
"(//*[@label='IP Address']/parent::*/XCUIElementTypeStaticText)[2]").text
|
||||
print("ip_address_element_text: ", ip_address_element_text)
|
||||
except Exception as e:
|
||||
try:
|
||||
time.sleep(4)
|
||||
print("Scrolling for checking ip address")
|
||||
scrollDown(setup_perfectoMobile)
|
||||
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:
|
||||
print("IP Address not Found")
|
||||
request.config.cache.set(key="select IP failed", value=str(e))
|
||||
|
||||
except Exception as e:
|
||||
request.config.cache.set(key="select additional info failed", value=str(e))
|
||||
# ---------------------Additional INFO-------------------------------
|
||||
|
||||
@@ -85,7 +85,7 @@ class TestToggleAirplaneModeBridgeModeEnterpriseTTLSSuiteA(object):
|
||||
connData = get_ToggleAirplaneMode_data
|
||||
|
||||
# Set Wifi/AP Mode
|
||||
ip, is_internet = gets_ip_add_for_checking_and_forgets_ssid_ios(request, ssidName, identity, ttls_passwd, setup_perfectoMobile_iOS, connData)
|
||||
ip, is_internet = gets_ip_add_eap_and_does_not_forget_ssid_ios(request, ssidName, identity, ttls_passwd, setup_perfectoMobile_iOS, connData)
|
||||
|
||||
if is_internet:
|
||||
if ip:
|
||||
|
||||
Reference in New Issue
Block a user