Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Retry logic when Error popup comes in Speed test #698

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions libs/perfecto_libs/android_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -7553,13 +7553,33 @@ def ookla_speed_test_android(request, setup_perfectoMobile, get_APToMobileDevice
driver = setup_perfectoMobile[0]
driver.switch_to.context('NATIVE_APP')
openApp('org.zwanoo.android.speedtest', setup_perfectoMobile)
WebDriverWait(driver, 30).until(
EC.presence_of_element_located((MobileBy.XPATH, "//*[@resource-id='org.zwanoo.android.speedtest:id/go_button']"))).click()
# Wait untill 2 minutes for the test to complete
WebDriverWait(driver, 120).until(
EC.presence_of_element_located((MobileBy.XPATH, "//*[@text='Test Again']")))
downloadSpeed = driver.find_element_by_xpath("//*[@text='DOWNLOAD']/parent::*/android.widget.TextView[3]").text
uploadSpeed = driver.find_element_by_xpath("//*[@text='UPLOAD']/parent::*/android.widget.TextView[3]").text
try:
WebDriverWait(driver, 30).until(
EC.presence_of_element_located(
(MobileBy.XPATH, "//*[@resource-id='org.zwanoo.android.speedtest:id/go_button']"))).click()
# Wait until 2 minutes for the test to complete
WebDriverWait(driver, 120).until(
EC.presence_of_element_located((MobileBy.XPATH, "//*[@text='Test Again']")))
downloadSpeed = driver.find_element_by_xpath("//*[@text='DOWNLOAD']/parent::*/android.widget.TextView[3]").text
uploadSpeed = driver.find_element_by_xpath("//*[@text='UPLOAD']/parent::*/android.widget.TextView[3]").text
except:
print("Exception in running Speed test, Trying Again")
try:
WebDriverWait(driver, 30).until(
EC.presence_of_element_located((MobileBy.XPATH, "//*[@text='OK']"))).click()
except:
print("No Error Popup, Trying Again")
try:
WebDriverWait(driver, 30).until(
EC.presence_of_element_located(
(MobileBy.XPATH, "//*[@resource-id='org.zwanoo.android.speedtest:id/go_button']"))).click()
# Wait until 2 minutes for the test to complete
WebDriverWait(driver, 120).until(
EC.presence_of_element_located((MobileBy.XPATH, "//*[@text='Test Again']")))
downloadSpeed = driver.find_element_by_xpath("//*[@text='DOWNLOAD']/parent::*/android.widget.TextView[3]").text
uploadSpeed = driver.find_element_by_xpath("//*[@text='UPLOAD']/parent::*/android.widget.TextView[3]").text
except:
print("Exception in running Speed test")
print(f"Download speed: {downloadSpeed}")
print(f"Upload speed: {uploadSpeed}")
return downloadSpeed, uploadSpeed
53 changes: 40 additions & 13 deletions libs/perfecto_libs/iOS_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -3613,19 +3613,46 @@ def return_upload_download_speed_iOS(request, setup_perfectoMobile, get_APToMobi
return downloadSpeed, uploadSpeed

def ookla_speed_test_iOS(request, setup_perfectoMobile, get_APToMobileDevice_data):
report = setup_perfectoMobile[1]
driver = setup_perfectoMobile[0]
driver.switch_to.context('NATIVE_APP')
openApp( 'com.ookla.speedtest', setup_perfectoMobile)
driver.find_element_by_xpath("//*[@label='GO']").click()
# Wait untill 2 minutes for the test to complete
WebDriverWait(driver, 120).until(
EC.presence_of_element_located((MobileBy.XPATH, "//*[@value='Test Again']")))
result = driver.find_element_by_xpath("//XCUIElementTypeOther[contains(@label,'Download Speed')]").text
device_model = getDeviceModelName(setup_perfectoMobile)
openApp('com.ookla.speedtest', setup_perfectoMobile)
if device_model == 'iPhone-7':
try:
report.step_start("Checking for continue")
WebDriverWait(driver, 20).until(
EC.presence_of_element_located((MobileBy.XPATH, "//*[@label='Continue']"))).click()
except:
print("Unable to see Continue permission")
try:
WebDriverWait(driver, 20).until(
EC.presence_of_element_located((MobileBy.XPATH, "//*[@label='GO']"))).click()
# Wait untill 2 minutes for the test to complete
WebDriverWait(driver, 120).until(
EC.presence_of_element_located((MobileBy.XPATH, "//*[@value='Test Again']")))
result = driver.find_element_by_xpath("//XCUIElementTypeOther[contains(@label,'Download Speed')]").text
except:
print("Exception in running Speed test, Trying Again")
try:
WebDriverWait(driver, 20).until(
EC.presence_of_element_located((MobileBy.XPATH, "//*[@label='OK']"))).click()
except:
print("No Error Popup")
try:
WebDriverWait(driver, 30).until(
EC.presence_of_element_located((MobileBy.XPATH, "//*[@label='GO']"))).click()
# Wait until 2 minutes for the test to complete
WebDriverWait(driver, 120).until(
EC.presence_of_element_located((MobileBy.XPATH, "//*[@value='Test Again']")))
result = driver.find_element_by_xpath("//XCUIElementTypeOther[contains(@label,'Download Speed')]").text
except:
print("Exception in running Speed test")
print(result)
downloadSpeed = result.split('Download Speed, ')[1].split('. ')[0]
uploadSpeed = result.split('Upload speed, ')[1].split('. ')[0]
downloadSpeed = str(downloadSpeed)[0:4]
uploadSpeed = str(uploadSpeed)[0:4]
print(f"Download speed: {downloadSpeed}")
print(f"Upload speed: {uploadSpeed}")
return downloadSpeed, uploadSpeed
download_speed = result.split('Download Speed, ')[1].split('. ')[0]
upload_speed = result.split('Upload speed, ')[1].split('. ')[0]
download_speed = str(download_speed)[0:4]
upload_speed = str(upload_speed)[0:4]
print(f"Download speed: {download_speed}")
print(f"Upload speed: {upload_speed}")
return download_speed, upload_speed