Wifi 7843 (#509)

* Updated the Captive portal android library

Signed-off-by: haricharan-jaka <haricharan.jaka@candelatech.com>

* Updated the Captive portal iOs library

Signed-off-by: haricharan-jaka <haricharan.jaka@candelatech.com>

* Updated the Captive portal android test cases

Signed-off-by: haricharan-jaka <haricharan.jaka@candelatech.com>

* Updated the Captive portal iOS test cases

Signed-off-by: haricharan-jaka <haricharan.jaka@candelatech.com>

* Updated Captive Portal Android library

Signed-off-by: haricharan-jaka <haricharan.jaka@candelatech.com>

* Removed the comments

Signed-off-by: haricharan-jaka <haricharan.jaka@candelatech.com>

* Rmeoved unnecessary markers

Signed-off-by: haricharan-jaka <haricharan.jaka@candelatech.com>
This commit is contained in:
Haricharan Jaka
2022-05-06 12:41:34 +05:30
committed by GitHub
parent 3e2e3222f7
commit 7172078187
4 changed files with 601 additions and 232 deletions

View File

@@ -2247,17 +2247,18 @@ def captive_portal_ios(request, WifiName, WifiPass, setup_perfectoMobile, connDa
openApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile)
try:
time.sleep(1)
time.sleep(2)
driver.implicitly_wait(2)
try:
print("Verifying Connected Wifi Connection")
report.step_start("Loading Wifi Page")
element = WebDriverWait(driver, 10).until(EC.presence_of_element_located((MobileBy.XPATH, "//XCUIElementTypeCell[@name='Wi-Fi']")))
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)
driver.implicitly_wait(4)
# --------------------To Turn on WIFi Switch if already OFF--------------------------------
try:
get_wifi_switch_element = driver.find_element_by_xpath("//*[@label='Wi-Fi' and @value='0']")
@@ -2274,7 +2275,7 @@ def captive_portal_ios(request, WifiName, WifiPass, setup_perfectoMobile, connDa
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")
print("Switch is OFF")
if get_wifi_switch_element_text == "1" or get_wifi_switch_element_text == 1:
print("WIFI Switch is ON")
@@ -2289,11 +2290,11 @@ def captive_portal_ios(request, WifiName, WifiPass, setup_perfectoMobile, connDa
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
return ip_address_element_text, is_internet
else:
print("Switch is Still OFF")
closeApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile)
#return is_internet
return ip_address_element_text, is_internet
except:
print("No switch element found")
except:
@@ -2303,22 +2304,29 @@ def captive_portal_ios(request, WifiName, WifiPass, setup_perfectoMobile, connDa
except:
print("Cannot find WIFI element")
closeApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile)
#return is_internet
return ip_address_element_text, is_internet
# ---------------------This is to Forget current connected SSID-------------------------------
try:
time.sleep(4)
print("getting in to Additional details")
additional_details_element = WebDriverWait(driver, 10).until(EC.presence_of_element_located((MobileBy.XPATH, "//*[@label='selected']/parent::*/parent::*/XCUIElementTypeButton[@label='More Info']")))
report.step_start("Clicking More Info")
additional_details_element = driver.find_element_by_xpath(
"//*[@label='selected']/parent::*/parent::*/XCUIElementTypeButton[@label='More Info']")
additional_details_element.click()
try:
time.sleep(2)
print("Forget Connected Network")
forget_ssid = WebDriverWait(driver, 10).until(EC.presence_of_element_located((MobileBy.XPATH, "//*[@label='Forget This Network']")))
forget_ssid = WebDriverWait(driver, 30).until(
EC.presence_of_element_located((MobileBy.XPATH, "//*[@label='Forget This Network']")))
forget_ssid.click()
print("Forget old ssid")
try:
time.sleep(2)
report.step_start("Forget SSID popup1")
forget_ssid_popup = driver.find_element_by_xpath("//*[@label='Forget']")
forget_ssid_popup = WebDriverWait(driver, 30).until(
EC.presence_of_element_located((MobileBy.XPATH, "//*[@label='Forget']")))
forget_ssid_popup.click()
print("**alert** Forget SSID popup killed **alert**")
@@ -2335,48 +2343,60 @@ def captive_portal_ios(request, WifiName, WifiPass, setup_perfectoMobile, connDa
print("Searching for Wifi: " + WifiName)
# allure.attach(name= body=str("Searching for Wifi: " + WifiName))
time.sleep(2)
report.step_start("Searching SSID")
print("Selecting Wifi: " + WifiName)
ssid_found = False
available_ssids = False
try:
for check_for_all_ssids in range(2):
for check_for_all_ssids in range(9):
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:
ssid_found = True
print(WifiName + " : Found in Device")
# allure.attach(name= body=str(WifiName + " : Found in Device"))
break
try:
driver.implicitly_wait(8)
report.step_start("Selecting SSID To Connect")
ssid_found = True
print(WifiName + " : Found in Device")
wifiSelElement = WebDriverWait(driver, 35).until(
EC.presence_of_element_located((MobileBy.XPATH, "//*[@label='" + WifiName + "']")))
print(wifiSelElement)
wifiSelElement.click()
print("Selecting SSID")
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))
closeApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile)
return ip_address_element_text, is_internet
pass
if not ssid_found:
print("could not found " + WifiName + " in device")
closeApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile)
return is_internet
return ip_address_element_text, 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-------------------------------
# ---------------------This is to Select SSID-------------------------------
# ---------------------Set Password-------------------------------
try:
driver.implicitly_wait(5)
print("Entering Password")
report.step_start("Entering Password")
wifiPassword = driver.find_element_by_xpath("//*[@label='Password']")
wifiPassword.send_keys(WifiPass)
except NoSuchElementException:
@@ -2385,12 +2405,25 @@ def captive_portal_ios(request, WifiName, WifiPass, setup_perfectoMobile, connDa
# ---------------------Click on join-------------------------------
try:
driver.implicitly_wait(4)
print("Selecting join")
report.step_start("Clicking JOIN")
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-------------------------------
# ---------------------check if internet-------------------------------
try:
driver.implicitly_wait(5)
WifiInternetErrMsg2 = driver.find_element_by_xpath("//*[@label='No Internet Connection']")
# = driver.find_element_by_xpath("//*[@label='No Internet Connection']").text
except Exception as e:
is_internet = True
print("No Wifi-AP Error Internet Error: " + WifiName)
# Need to add Wait for Selected Wifi Xpath
# time.sleep(3)
# ---------------------check if internet-------------------------------
try:
time.sleep(8)
try:
@@ -2438,37 +2471,87 @@ def captive_portal_ios(request, WifiName, WifiPass, setup_perfectoMobile, connDa
# ---------------------Additional INFO-------------------------------
try:
time.sleep(4)
print("Selecting SSID: ",WifiName)
report.step_start("Selecting SSID")
additional_details_element = WebDriverWait(driver, 30).until(
driver.implicitly_wait(5)
print("Selecting SSID: ", WifiName)
report.step_start("Additional details of SSID")
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()
try:
time.sleep(5)
driver.implicitly_wait(2)
report.step_start("Checking SSID Name as Expected")
print("Checking SSID Name")
ssidname_text = driver.find_element_by_xpath("//*[@label='" + WifiName + "']").text
print(ssidname_text)
if (ssidname_text == WifiName):
print("SSID Matched")
allure.attach(name="SSID Matched ", body=str(WifiName))
else:
print("SSID Not Matched")
allure.attach(name="SSID Not Matched ", body=str(WifiName))
reportFlag = False
assert reportFlag
except:
print("SSID is not Checked in more Info")
try:
report.step_start("Checking WiFi Address")
print("Checking WIFI address")
# (//*[@label="IP Address"]/parent::*/XCUIElementTypeStaticText)[2]
wifi_address_element_text = driver.find_element_by_xpath(
"(//*[@label='Wi-Fi Address']/parent::*/XCUIElementTypeStaticText)[2]").text
print("wifi_address_element_text: ", wifi_address_element_text)
allure.attach(name="Connected SSID WiFi-Address: ", body=str(wifi_address_element_text))
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]
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)
# is_internet=True
except Exception as e:
print("IP Address not Found")
request.config.cache.set(key="select IP failed", value=str(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))
try:
driver.implicitly_wait(5)
WifiInternetErrMsg2 = driver.find_element_by_xpath("//*[@label='No Internet Connection']")
except Exception as e:
is_internet = True
print("No Wifi-AP Error Internet Error: " + WifiName)
report.step_start("Forget Network")
forget_ssid = WebDriverWait(driver, 30).until(
EC.presence_of_element_located((MobileBy.XPATH, "//*[@label='Forget This Network']")))
forget_ssid.click()
print("Forget old ssid")
# time.sleep(2)
# driver.implicitly_wait(3)
try:
report.step_start("Forget Network popup")
forget_ssid_popup = WebDriverWait(driver, 30).until(
EC.presence_of_element_located((MobileBy.XPATH, "//*[@label='Forget']")))
forget_ssid_popup.click()
except:
print("in popup exception")
except:
print("error on ssid element")
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)
closeApp(connData["bundleId-iOS-Settings"], setup_perfectoMobile)
return ip_address_element_text, is_internet
# Returns whether the ssid is currently visible