Skip to content

Commit

Permalink
Merge pull request #183 from nodlesh/fix/appium-2-alignment
Browse files Browse the repository at this point in the history
fix: appium 2 alignment
  • Loading branch information
nodlesh authored Aug 1, 2023
2 parents 8674aa1 + e700880 commit cc3777d
Show file tree
Hide file tree
Showing 11 changed files with 94 additions and 63 deletions.
5 changes: 4 additions & 1 deletion aries-mobile-tests/Dockerfile.harness
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.7-buster
FROM python:3.9-bullseye
COPY ./aries-mobile-tests/requirements.txt /aries-mobile-test-harness/
WORKDIR /aries-mobile-test-harness
RUN pip install -r requirements.txt
Expand All @@ -12,6 +12,9 @@ RUN \

RUN apt update && apt install -y chromium

# workaround for chromium crash reports warning
RUN mkdir -p "/root/.config/chromium/Crash Reports/pending"

COPY . /aries-mobile-test-harness
WORKDIR /aries-mobile-test-harness/aries-mobile-tests
ENTRYPOINT ["behave"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
from sys import platform
from decouple import config
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.core.utils import ChromeType
from webdriver_manager.core.os_manager import ChromeType
# import Page Objects needed
from pageobjects.bc_wallet.issuer_get_authcode_interface.bc_vp_issuer_get_authcode_interface_gapi import BCVPIssuerGetAuthCodeInterface
from agent_factory.bc_vp.pageobjects.authenticate_with_page import AuthenticateWithPage
Expand Down Expand Up @@ -50,11 +50,9 @@ def __init__(self, endpoint):
print("Starting Chromium on linux for Issuer Agent")
options = Options()
options.add_argument("--no-sandbox")
# options.add_argument("--disable-dev-shm-usage")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--headless")
self.driver = webdriver.Chrome(options=options, service=Service(
ChromeDriverManager(chrome_type=ChromeType.CHROMIUM).install()))
#self.driver = webdriver.Chrome(options=options, service=Service(ChromeDriverManager().install()))
self.driver = webdriver.Chrome(options=options, service=Service(ChromeDriverManager(chrome_type=ChromeType.CHROMIUM).install()))
else:
print("Starting Chrome on Mac or Windows for Issuer Agent")
self.driver = webdriver.Chrome(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.core.utils import ChromeType
from webdriver_manager.core.os_manager import ChromeType
# import Page Objects needed
from agent_factory.candy_uvp.pageobjects.terms_of_service_page import TermsOfServicePage
from agent_factory.candy_uvp.pageobjects.request_credential_page import RequestCredentialPage
from agent_factory.candy_uvp.pageobjects.review_and_confirm_page import ReviewAndConfirmPage
from agent_factory.candy_uvp.pageobjects.connect_with_issuer_page import ConnectWithIssuerPage
from agent_factory.candy_uvp.pageobjects.issuing_credential_page import IssuingCredentialPage

#import json
#from agent_test_utils import get_qr_code_from_invitation
#from random import randint

class CANdy_UVP_IssuerAgentInterface(IssuerAgentInterface):

Expand Down Expand Up @@ -46,10 +43,9 @@ def __init__(self, endpoint):
print("Starting Chromium on linux for Issuer Agent")
options = Options()
options.add_argument("--no-sandbox")
#options.add_argument("--disable-dev-shm-usage")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--headless")
self.driver = webdriver.Chrome(options=options, service=Service(ChromeDriverManager(chrome_type=ChromeType.CHROMIUM).install()))
#self.driver = webdriver.Chrome(options=options, service=Service(ChromeDriverManager().install()))
else:
print("Starting Chrome on Mac or Windows for Issuer Agent")
self.driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
Expand Down
26 changes: 17 additions & 9 deletions aries-mobile-tests/config.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
{
"capabilities": {
"appPackage": "ca.bc.gov.BCWallet",
"appium:appActivity": "ca.bc.gov.BCWallet.MainActivity",
"platformName": "Android",
"app": "/Users/Shel/Projects/BC.gov/apps/bifold-bc/AriesBifold-209.apk",
"deviceName": "Android Accelerated Oreo",
"udid": "emulator-5554",
"automationName": "UiAutomator2",
"autoGrantPermissions": true,
"fullReset": false
"firstMatch": [
{
"platformName": "iOS",
"appium:options": {
"app": "storage:filename=BCWallet-1083.ipa",
"autoAcceptAlerts": true,
"autoDismissAlerts": true,
"automationName": "xcuitest"
},
"sauce:options": {
"appiumVersion": "2.0.0",
"fullReset": true,
"sauceLabsImageInjectionEnabled": true,
"sessionCreationRetry": "3"
}
}
]
}
}
14 changes: 8 additions & 6 deletions aries-mobile-tests/device_service_handler/sauce_labs_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@ def set_desired_capabilities(self, config: dict = None):

# Handle posiible special options
if 'name' in config:
self._CONFIG['capabilities']['sauce:options'] = {
'name': config['name']
}
# Check if 'sauce:options' already exists
if 'sauce:options' not in self._CONFIG['capabilities']['firstMatch'][0]:
self._CONFIG['capabilities']['firstMatch'][0]['sauce:options'] = {}

# Insert the 'name' key under 'sauce:options'
self._CONFIG['capabilities']['firstMatch'][0]['sauce:options']['name'] = config['name']
config.pop('name')

# Handle common options and capabilities
for item in config:
self._CONFIG['capabilities'][item] = config[item]
#self._CONFIG['capabilities']['fullReset'] = True
self._desired_capabilities = self._CONFIG['capabilities']
self._CONFIG['capabilities']['firstMatch'][0][item] = config[item]
self._desired_capabilities = self._CONFIG['capabilities']['firstMatch'][0]
print("\n\nDesired Capabilities passed to Appium:")
print(json.dumps(self._desired_capabilities, indent=4))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.core.utils import ChromeType
from webdriver_manager.core.os_manager import ChromeType
# import Page Objects needed
from pageobjects.bc_wallet.holder_get_invite_interface.pageobjects.gmail_login_page import GmailLoginPage
from pageobjects.bc_wallet.holder_get_invite_interface.pageobjects.gmail_email_page import GmailEmailPage
Expand All @@ -34,11 +34,10 @@ def __init__(self, endpoint):
print("Starting Chromium on linux for Issuer Agent")
options = Options()
options.add_argument("--no-sandbox")
# options.add_argument("--disable-dev-shm-usage")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--headless")
self.driver = webdriver.Chrome(options=options, service=Service(
ChromeDriverManager(chrome_type=ChromeType.CHROMIUM).install()))
#self.driver = webdriver.Chrome(options=options, service=Service(ChromeDriverManager().install()))
else:
print("Starting Chrome on Mac or Windows for Issuer Agent")
self.driver = webdriver.Chrome(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.core.utils import ChromeType
from webdriver_manager.core.os_manager import ChromeType
# import Page Objects needed
from pageobjects.bc_wallet.holder_get_invite_interface.pageobjects.gmail_login_page import GmailLoginPage
from pageobjects.bc_wallet.holder_get_invite_interface.pageobjects.gmail_email_page import GmailEmailPage
Expand All @@ -34,11 +34,10 @@ def __init__(self, endpoint):
print("Starting Chromium on linux for Issuer Agent")
options = Options()
options.add_argument("--no-sandbox")
# options.add_argument("--disable-dev-shm-usage")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--headless")
self.driver = webdriver.Chrome(options=options, service=Service(
ChromeDriverManager(chrome_type=ChromeType.CHROMIUM).install()))
#self.driver = webdriver.Chrome(options=options, service=Service(ChromeDriverManager().install()))
else:
print("Starting Chrome on Mac or Windows for Issuer Agent")
self.driver = webdriver.Chrome(
Expand Down
11 changes: 3 additions & 8 deletions aries-mobile-tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
behave
allure-behave
#behave==1.2.6
browserstack-local==1.2.2
SauceClient
paver==1.3.4
#selenium==3.141.0
selenium==4.9.0
selenium
psutil==5.7.2
#Appium-Python-Client==0.52;python_version < '3.0'
#Appium-Python-Client==1.0.2;python_version >= '3.0'
Appium-Python-Client==2.9.0
Appium-Python-Client
qrcode[pil]~=6.1
webdriver-manager==3.8.3
webdriver-manager
google-api-python-client
google-auth-httplib2
google-auth-oauthlib
Expand Down
24 changes: 16 additions & 8 deletions aries-mobile-tests/sl_android_config.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
{
"capabilities": {
"project": "BC Wallet",
"build": "build-1",
"platformName": "Android",
"app":"storage:filename=app-release.apk",
"sessionCreationRetry" : "3",
"sauceLabsImageInjectionEnabled": true,
"autoGrantPermissions": true,
"fullReset": true
"firstMatch": [
{
"platformName": "Android",
"appium:options": {
"app": "storage:filename=BCWallet-1083.aab",
"autoGrantPermissions": true,
"automationName": "UiAutomator2"
},
"sauce:options": {
"appiumVersion": "2.0.0",
"fullReset": true,
"sauceLabsImageInjectionEnabled": true,
"sessionCreationRetry": "3"
}
}
]
}
}
27 changes: 17 additions & 10 deletions aries-mobile-tests/sl_ios_config.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
{
"capabilities": {
"project": "BC Wallet",
"build": "build-1",
"platformName": "iOS",
"app": "storage:filename=AriesBifold-76.ipa",
"sessionCreationRetry": "3",
"sauceLabsImageInjectionEnabled": true,
"autoAcceptAlerts": true,
"fullReset": true,
"shouldTerminateApp": true,
"cacheId": "123456789"
"firstMatch": [
{
"platformName": "iOS",
"appium:options": {
"app": "storage:filename=BCWallet-1083.ipa",
"autoAcceptAlerts": true,
"autoDismissAlerts": true,
"automationName": "xcuitest"
},
"sauce:options": {
"appiumVersion": "2.0.0",
"fullReset": true,
"sauceLabsImageInjectionEnabled": true,
"sessionCreationRetry": "3"
}
}
]
}
}
22 changes: 19 additions & 3 deletions manage
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ if [ "${PWD_HOST_FQDN}" != "" ]; then
fi
fi

# Set default platform to linux/amd64 when running on Arm based MAC since there are no arm based images available currently.
if [[ $OSTYPE == 'darwin'* ]]; then
architecture=$(uname -m)
if [[ "${architecture}" == 'arm'* ]] || [[ "${architecture}" == 'aarch'* ]]; then
export DOCKER_DEFAULT_PLATFORM=linux/amd64
fi
fi

# =================================================================================================================
# Usage:
# -----------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -218,20 +226,28 @@ modifyConfigJson() {
fi
fi

contents="$(jq --arg DEVICE_PLATFORM "${DEVICE_PLATFORM}" '.capabilities |= . + { "platformName": $DEVICE_PLATFORM }' ./aries-mobile-tests/config.json)" && \
echo "${contents}" > ./aries-mobile-tests/config.json
# contents="$(jq --arg DEVICE_PLATFORM "${DEVICE_PLATFORM}" '.capabilities |= . + { "platformName": $DEVICE_PLATFORM }' ./aries-mobile-tests/config.json)" && \
# echo "${contents}" > ./aries-mobile-tests/config.json

build_name="Wallet-Build $(date +'%m/%d/%y %H:%M:%S')"

if [[ "${DEVICE_CLOUD}" == "SauceLabs" ]]; then
contents="$(jq --arg APP_NAME "storage:filename=${APP_NAME}" '.capabilities |= . + { "appium:app": $APP_NAME }' ./aries-mobile-tests/config.json)" && \
# contents="$(jq --arg APP_NAME "storage:filename=${APP_NAME}" '.capabilities |= . + { "appium:app": $APP_NAME }' ./aries-mobile-tests/config.json)" && \
# echo "${contents}" > ./aries-mobile-tests/config.json
contents="$(jq --arg DEVICE_PLATFORM "${DEVICE_PLATFORM}" '.capabilities.firstMatch[0] |= . + { "platformName": $DEVICE_PLATFORM }' ./aries-mobile-tests/config.json)" && \
echo "${contents}" > ./aries-mobile-tests/config.json
jq --arg APP_NAME "storage:filename=${APP_NAME}" '.capabilities.firstMatch[0]."appium:options".app = $APP_NAME' ./aries-mobile-tests/config.json > tmp_config.json
mv tmp_config.json ./aries-mobile-tests/config.json
elif [[ "${DEVICE_CLOUD}" == "LambdaTest" ]]; then
contents="$(jq --arg DEVICE_PLATFORM "${DEVICE_PLATFORM}" '.capabilities |= . + { "platformName": $DEVICE_PLATFORM }' ./aries-mobile-tests/config.json)" && \
echo "${contents}" > ./aries-mobile-tests/config.json
contents="$(jq --arg APP_NAME "${APP_NAME}" --arg BUILD "${BUILD:=$build_name}" '.capabilities."lt:options" |= . + {"app": $APP_NAME, "build": $BUILD }' ./aries-mobile-tests/config.json)" && \
echo "${contents}" > ./aries-mobile-tests/config.json
contents="$(jq 'del(.capabilities.platformName)' ./aries-mobile-tests/config.json)"
echo "${contents}" > ./aries-mobile-tests/config.json
else
contents="$(jq --arg DEVICE_PLATFORM "${DEVICE_PLATFORM}" '.capabilities |= . + { "platformName": $DEVICE_PLATFORM }' ./aries-mobile-tests/config.json)" && \
echo "${contents}" > ./aries-mobile-tests/config.json
contents="$(jq --arg APP_NAME "${APP_NAME}" '.capabilities |= . + { "app": $APP_NAME }' ./aries-mobile-tests/config.json)" && \
echo "${contents}" > ./aries-mobile-tests/config.json
fi
Expand Down

0 comments on commit cc3777d

Please sign in to comment.