Skip to content

Commit

Permalink
Merge pull request openwallet-foundation#127 from nodlesh/fix/CANdy-t…
Browse files Browse the repository at this point in the history
…est-failures

Fix BC Wallet CANdy tests
  • Loading branch information
nodlesh committed Jan 25, 2023
2 parents 1a91392 + 4788406 commit 5ec59bd
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from PIL import Image
from agent_factory.candy_uvp.pageobjects.webbasepage import WebBasePage
from selenium.webdriver.common.by import By
from pageobjects.basepage import WaitCondition
import base64
#from candy_uvp.pageobjects.connect_with_issuer_page import ConnectWithIssuerPage

Expand All @@ -13,17 +14,16 @@ class ConnectWithIssuerPage(WebBasePage):
qr_code_locator = (By.XPATH, '//*[@id="app"]/div/main/div/div/div/img')


def on_this_page(self):
#print(self.driver.page_source)
def on_this_page(self):
return super().on_this_page(self.on_this_page_text_locator)

def get_qr_code(self):
if self.on_this_page():
qrcode_element = self.find_by(self.qr_code_locator)
self.driver.save_screenshot("qrcode.png")
#qrcode = Image.open("qrcode.png")
qrcode = base64.b64encode(open("qrcode.png", "rb").read())
return qrcode.decode('utf-8')
# if self.on_this_page():
qrcode_element = self.find_by(self.qr_code_locator, wait_condition=WaitCondition.VISIBILITY_OF_ELEMENT_LOCATED)
self.driver.save_screenshot("qrcode.png")
#qrcode = Image.open("qrcode.png")
qrcode = base64.b64encode(open("qrcode.png", "rb").read())
return qrcode.decode('utf-8')

else:
raise Exception(f"App not on the {type(self)} page")
# else:
# raise Exception(f"App not on the {type(self)} page")
22 changes: 22 additions & 0 deletions aries-mobile-tests/features/steps/bc_wallet/credential_offer.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,31 @@ def step_impl(context):

@then('holder is brought to the credential offer screen')
def step_impl(context):
# Workaround for bug 645
context.execute_steps(f'''
When the connection takes too long reopen app and select notification
''')

#assert context.thisConnectingPage.wait_for_connection()

context.thisCredentialOfferPage = CredentialOfferPage(context.driver)
assert context.thisCredentialOfferPage.on_this_page()

@when('the connection takes too long reopen app and select notification')
def step_impl(context):
# Workaround for bug 645
if "Workaround645" in context.tags:
if context.thisConnectingPage.is_connecting_taking_too_long():
context.thisHomePage = context.thisConnectingPage.select_go_back_to_home()
context.execute_steps(f'''
When they have closed the app
When they relaunch the app
When authenticates with thier biometrics
''')
# Check for the notification on the Home Page
context.thisHomePage.select_credential_offer_notification()



@then('they can view the contents of the credential')
def step_impl(context):
Expand Down
8 changes: 5 additions & 3 deletions aries-mobile-tests/features/steps/bc_wallet/proof.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,11 @@ def step_impl(context):
context.thisConnectingPage = context.thisNavBar.select_scan()

# If this is the first time the user selects scan, then they will get a Camera Privacy Policy that needs to be dismissed
context.thisCameraPrivacyPolicyPage = CameraPrivacyPolicyPage(context.driver)
if context.thisCameraPrivacyPolicyPage.on_this_page():
context.thisCameraPrivacyPolicyPage.select_okay()
#if autoGrantPermissions is in Capabilities = True, and platform is Android, skip this
if ('autoGrantPermissions' in context.driver.capabilities and context.driver.capabilities['autoGrantPermissions'] == False) or (context.driver.capabilities['platformName'] == 'iOS'):
context.thisCameraPrivacyPolicyPage = CameraPrivacyPolicyPage(context.driver)
if context.thisCameraPrivacyPolicyPage.on_this_page():
context.thisCameraPrivacyPolicyPage.select_okay()

@given('the user has a connectionless proof request for access to PCTF Chat')
def step_impl(context):
Expand Down
10 changes: 6 additions & 4 deletions aries-mobile-tests/features/steps/bc_wallet/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,12 @@ def step_impl(context):
@when('authenticates with thier biometrics')
def step_impl(context):
# Check to see if the Biometrics page is displayed
context.thisBiometricsPage = BiometricsPage(context.driver)
assert context.thisBiometricsPage.on_this_page()
context.device_service_handler.biometrics_authenticate(True)
assert context.thisBiometricsPage.on_this_page() == False
#if ('autoGrantPermissions' in context.driver.capabilities and context.driver.capabilities['autoGrantPermissions'] == False) or (context.driver.capabilities['platformName'] == 'iOS'):
if (context.driver.capabilities['platformName'] == 'iOS'):
context.thisBiometricsPage = BiometricsPage(context.driver)
assert context.thisBiometricsPage.on_this_page()
context.device_service_handler.biometrics_authenticate(True)
assert context.thisBiometricsPage.on_this_page() == False


@when('fails to authenticate with thier biometrics once')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from pageobjects.basepage import BasePage
from pageobjects.basepage import WaitCondition


# These classes can inherit from a BasePage to do commone setup and functions
Expand All @@ -13,6 +14,7 @@ class CameraPrivacyPolicyPage(BasePage):
on_this_page_locator = (AppiumBy.ID, "com.ariesbifold:id/AllowCameraUse")
allow_button_locator = (AppiumBy.ID, "com.ariesbifold:id/Allow")
not_now_button_locator = (AppiumBy.ID, "com.ariesbifold:id/NotNow")
system_allow_while_using_app = (AppiumBy.ID, "com.android.permissioncontroller:id/permission_allow_foreground_only_button")


def on_this_page(self):
Expand All @@ -28,6 +30,11 @@ def select_not_now(self):
def select_okay(self):
if self.on_this_page():
self.find_by(self.allow_button_locator).click()
if self.driver.capabilities['platformName'] == 'Android':
self.select_system_allow_while_using_app()
return True
else:
raise Exception(f"App not on the {type(self)} page")

def select_system_allow_while_using_app(self):
self.find_by(self.system_allow_while_using_app, wait_condition=WaitCondition.ELEMENT_TO_BE_CLICKABLE).click()
15 changes: 11 additions & 4 deletions aries-mobile-tests/pageobjects/bc_wallet/connecting.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import time
from appium.webdriver.common.mobileby import MobileBy
from appium.webdriver.common.appiumby import AppiumBy
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from pageobjects.basepage import BasePage
Expand All @@ -15,8 +15,9 @@ class ConnectingPage(BasePage):

# Locators
on_this_page_text_locator = "Just a moment"
on_this_page_locator = (MobileBy.ID, "com.ariesbifold:id/CredentialOnTheWay")
back_to_home_locator = "Home"
on_this_page_locator = (AppiumBy.ID, "com.ariesbifold:id/CredentialOnTheWay")
taking_too_long_locator = (AppiumBy.ID, "com.ariesbifold:id/TakingTooLong")
back_to_home_locator = (AppiumBy.ID, "com.ariesbifold:id/BackToHome")

def on_this_page(self):
timeout = 10
Expand All @@ -26,12 +27,18 @@ def on_this_page(self):

def select_go_back_to_home(self):
if self.on_this_page():
self.find_by_accessibility_id(self.back_to_home_locator).click()
self.find_by(self.back_to_home_locator).click()
from pageobjects.bc_wallet.home import HomePage
return HomePage(self.driver)
else:
raise Exception(f"App not on the {type(self)} page")

def is_connecting_taking_too_long(self):
if self.find_by(self.taking_too_long_locator, timeout=40, wait_condition=WaitCondition.VISIBILITY_OF_ELEMENT_LOCATED):
return True
else:
return False

def wait_for_connection(self, timeout=300):
# Set up logging
logger = logging.getLogger(__name__)
Expand Down

0 comments on commit 5ec59bd

Please sign in to comment.