Im running test automation for app on iOS and Android, have to scan QR code from email(registration reason). So:
deps:
desired_capabilities = {
'platformName': 'iOS',
'udid': f'{set_udid}',
'appium:automationName': 'Flutter',
'app': f'{app_path}',
'appium:bundleId': f'{bundle_id}',
'xcodeOrgId': 'L8JZ6843HL',
'xcodeSigningId': '0FB7117FD82DED81C35334BB65E227214DBC4762',
'appium:newCommandTimeout': 2000,
'appium:clearSystemFiles': True,
'fullReset': True,
'appium:autoAcceptAlerts': True
}
def desired_capa_android(set_udid, app_path):
"""Capabilities for Android device"""
desired_capabilities = {
'platformName': 'Android',
'udid': f'{set_udid}',
'appium:automationName': 'Flutter',
'appium:appPackage': Constants.ANDROID_APP_NAME,
'appium:appActivity': '.MainActivity',
'appium:realDevice': True,
'appium:newCommandTimeout': 1000,
'appium:autoGrantPermissions': True,
'appium:nativeWebScreenshot': True,
'appium:adbExecTimeout': 120000,
'appium:clearSystemFiles': True,
# 'appium:fullReset': False,
'androidInstallTimeout': 900000,
'appium:app': f'{app_path}'
}
function to get qr code from mail:
def get_qr_code_from_email_body(email_body):
soup = BeautifulSoup(email_body, 'html.parser')
manual_code_div = soup.find('div', style=lambda value: value and 'word-break: break-all' in value)
if manual_code_div:
return manual_code_div.text.strip().replace('n', '')
function to simulate qr reader when camera is open when test is running:
def simulate_qr_scan(qr_code, udid=None):
command = [
'xcrun', 'simctl', 'io', 'booted', 'simulate', 'barcode', '--type',
'qr', qr_code
]
try:
subprocess.run(command, check=True)
except subprocess.CalledProcessError as e:
print(f'Failed to simulate QR code scan: {e}')
Result of this function is nothing. Nothing happend and tests are failing. Anyone can show me what im doing wrong?