From afaa4f21e19144b588df2966748c7fa91837e671 Mon Sep 17 00:00:00 2001 From: rconner46 Date: Wed, 6 Aug 2025 11:10:00 -0500 Subject: [PATCH] Update capability conversion script to cover some other potential issues --- scripts/appium-conversion.py | 452 +++++++++++++++++++---------------- 1 file changed, 252 insertions(+), 200 deletions(-) diff --git a/scripts/appium-conversion.py b/scripts/appium-conversion.py index 8186f26..6fcf2af 100644 --- a/scripts/appium-conversion.py +++ b/scripts/appium-conversion.py @@ -2,216 +2,268 @@ import sys import os +unused_applause_options = [ + ("isStrict", ["true", "false"]), + ("isMobileNative", ["false"]), +] + +# A list of Appium capabilities that need to be updated to use the appium prefix. +# Each entry in the list is a tuple containing the capability name and a list of matching scopes for update. +capabilities_to_update = [ + ("adbExecTimeout",["all"]), + ("adbPort",["all"]), + ("absoluteWebLocations",["all"]), + ("additionalWebviewBundleIds",["all"]), + ("allowDelayAdb",["all"]), + ("allowProvisioningDeviceRegistration",["all"]), + ("allowTestPackages",["all"]), + ("androidInstallTimeout",["all"]), + ("app",["all"]), + ("appActivity",["all"]), + ("appInstallStrategy",["all"]), + ("appPackage",["all"]), + ("appPushTimeout",["all"]), + ("appWaitActivity",["all"]), + ("appWaitDuration",["all"]), + ("appWaitForLaunch",["all"]), + ("appWaitPackage",["all"]), + ("autoAcceptAlerts",["all"]), + ("autoDismissAlerts",["all"]), + ("autoFillPasswords",["all"]), + ("autoGrantPermissions",["all"]), + ("autoLaunch",["all"]), + ("autoWebview",["all"]), + ("autoWebviewName",["all"]), + ("autoWebviewTimeout",["all"]), + ("automationName",["all"]), + ("avd",["all"]), + ("avdArgs",["all"]), + ("avdEnv",["all"]), + ("avdLaunchTimeout",["all"]), + ("avdReadyTimeout",["all"]), + ("buildToolsVersion",["all"]), + ("bundleId",["all"]), + ("calendarAccessAuthorized",["all"]), + ("calendarFormat",["all"]), + ("chromeLoggingPrefs",["all"]), + ("chromeOptions",["all"]), + ("chromedriverArgs",["all"]), + ("chromedriverChromeMappingFile",["all"]), + ("chromedriverDisableBuildCheck",["all"]), + ("chromedriverExecutable",["all"]), + ("chromedriverExecutableDir",["all"]), + ("chromedriverPort",["all"]), + ("chromedriverPorts",["all"]), + ("chromedriverUseSystemExecutable",["all"]), + ("clearDeviceLogsOnStart",["all"]), + ("clearSystemFiles",["all"]), + ("commandTimeouts",["all"]), + ("connectHardwareKeyboard",["all"]), + ("customSSLCert",["all"]), + ("derivedDataPath",["all"]), + ("deviceName",["mobileweb_saucelabs", "mobilenative_all", "native_all"]), + ("disableAutomaticScreenshots",["all"]), + ("disableSuppressAccessibilityService",["all"]), + ("disableWindowAnimation",["all"]), + ("dontStopAppOnReset",["all"]), + ("enableAsyncExecuteFromHttps",["all"]), + ("enablePerformanceLogging",["all"]), + ("enableWebviewDetailsCollection",["all"]), + ("enforceAppInstall",["all"]), + ("enforceFreshSimulatorCreation",["all"]), + ("ensureWebviewsHavePages",["all"]), + ("extractChromeAndroidPackageFromContextName",["all"]), + ("forceAppLaunch",["all"]), + ("forceSimulatorSoftwareKeyboardPresence",["all"]), + ("fullContextList",["all"]), + ("fullReset",["all"]), + ("gpsEnabled",["all"]), + ("hideKeyboard",["all"]), + ("ignoreHiddenApiPolicyError",["all"]), + ("includeDeviceCapsToSessionInfo",["all"]), + ("includeSafariInWebviews",["all"]), + ("injectedImageProperties",["all"]), + ("intentAction",["all"]), + ("intentCategory",["all"]), + ("intentFlags",["all"]), + ("iosInstallPause",["all"]), + ("iosSimulatorLogsPredicate",["all"]), + ("isHeadless",["all"]), + ("keepKeyChains",["all"]), + ("keyAlias",["all"]), + ("keyPassword",["all"]), + ("keychainPassword",["all"]), + ("keychainPath",["all"]), + ("keychainsExcludePatterns",["all"]), + ("keystorePassword",["all"]), + ("keystorePath",["all"]), + ("language",["all"]), + ("launchWithIDB",["all"]), + ("locale",["all"]), + ("localeScript",["all"]), + ("localizableStringsDir",["all"]), + ("logcatFilterSpecs",["all"]), + ("logcatFormat",["all"]), + ("maxTypingFrequency",["all"]), + ("mjpegScreenshotUrl",["all"]), + ("mjpegServerPort",["all"]), + ("mockLocationApp",["all"]), + ("nativeWebScreenshot",["all"]), + ("nativeWebTap",["all"]), + ("nativeWebTapStrict",["all"]), + ("networkSpeed",["all"]), + ("newCommandTimeout",["all"]), + ("noReset",["all"]), + ("noSign",["all"]), + ("optionalIntentArguments",["all"]), + ("orientation",["all"]), + ("otherApps",["all"]), + ("permissions",["all"]), + ("platformVersion",["all"]), + ("prebuiltWDAPath",["all"]), + ("printPageSourceOnFindFailure",["all"]), + ("processArguments",["all"]), + ("recreateChromeDriverSessions",["all"]), + ("reduceMotion",["all"]), + ("reduceTransparency",["all"]), + ("remoteAdbHost",["all"]), + ("remoteAppsCacheLimit",["all"]), + ("resetLocationService",["all"]), + ("resetOnSessionStartOnly",["all"]), + ("resultBundlePath",["all"]), + ("resultBundleVersion",["all"]), + ("safariAllowPopups",["all"]), + ("safariGarbageCollect",["all"]), + ("safariGlobalPreferences",["all"]), + ("safariIgnoreFraudWarning",["all"]), + ("safariIgnoreWebHostnames",["all"]), + ("safariInitialUrl",["all"]), + ("safariLogAllCommunication",["all"]), + ("safariLogAllCommunicationHexDump",["all"]), + ("safariOpenLinksInBackground",["all"]), + ("safariSocketChunkSize",["all"]), + ("safariWebInspectorMaxFrameLength",["all"]), + ("scaleFactor",["all"]), + ("screenshotQuality",["all"]), + ("shouldTerminateApp",["all"]), + ("shouldUseSingletonTestManager",["all"]), + ("showChromedriverLog",["all"]), + ("showIOSLog",["all"]), + ("showXcodeLog",["all"]), + ("shutdownOtherSimulators",["all"]), + ("simpleIsVisibleCheck",["all"]), + ("simulatorDevicesSetPath",["all"]), + ("simulatorPasteboardAutomaticSync",["all"]), + ("simulatorStartupTimeout",["all"]), + ("simulatorTracePointer",["all"]), + ("simulatorWindowCenter",["all"]), + ("skipDeviceInitialization",["all"]), + ("skipLogCapture",["all"]), + ("skipLogcatCapture",["all"]), + ("skipServerInstallation",["all"]), + ("skipUnlock",["all"]), + ("suppressKillServer",["all"]), + ("systemPort",["all"]), + ("timeZone",["all"]), + ("udid",["all"]), + ("uiautomator2ServerInstallTimeout",["all"]), + ("uiautomator2ServerLaunchTimeout",["all"]), + ("uiautomator2ServerReadTimeout",["all"]), + ("uninstallOtherPackages",["all"]), + ("unlockKey",["all"]), + ("unlockStrategy",["all"]), + ("unlockSuccessTimeout",["all"]), + ("unlockType",["all"]), + ("updatedWDABundleId",["all"]), + ("useJSONSource",["all"]), + ("useKeystore",["all"]), + ("useNativeCachingStrategy",["all"]), + ("useNewWDA",["all"]), + ("usePrebuiltWDA",["all"]), + ("usePreinstalledWDA",["all"]), + ("useSimpleBuildTest",["all"]), + ("useXctestrunFile",["all"]), + ("userProfile",["all"]), + ("waitForIdleTimeout",["all"]), + ("waitForQuiescence",["all"]), + ("wdaBaseUrl",["all"]), + ("wdaConnectionTimeout",["all"]), + ("wdaEventloopIdleDelay",["all"]), + ("wdaLaunchTimeout",["all"]), + ("wdaLocalPort",["all"]), + ("wdaStartupRetries",["all"]), + ("wdaStartupRetryInterval",["all"]), + ("webDriverAgentUrl",["all"]), + ("webkitResponseTimeout",["all"]), + ("webviewConnectRetries",["all"]), + ("webviewConnectTimeout",["all"]), + ("webviewDevtoolsPort",["all"]), + ("xcodeConfigFile",["all"]), + ("xcodeOrgId",["all"]), + ("xcodeSigningId",["all"]), + ("commandTimeout", ["all"]), + ("deviceOrientation", ["all"]), + ("idleTimeout",["all"]), + +] + # Conversion script for migrating appium capabilities to use the appium prefix. This is required for the new version of appium # that is imported by the Java SDK 6.1.0 and later. def update_appium_capabilities(filepath): with open(filepath, 'r') as infile: contents = infile.read() - capabilities = [ - "adbExecTimeout", - "adbPort", - "absoluteWebLocations", - "additionalWebviewBundleIds", - "allowDelayAdb", - "allowProvisioningDeviceRegistration", - "allowTestPackages", - "androidInstallTimeout", - "app", - "appActivity", - "appInstallStrategy", - "appPackage", - "appPushTimeout", - "appWaitActivity", - "appWaitDuration", - "appWaitForLaunch", - "appWaitPackage", - "autoAcceptAlerts", - "autoFillPasswords", - "autoGrantPermissions", - "autoLaunch", - "autoWebview", - "autoWebviewName", - "autoWebviewTimeout", - "automationName", - "avd", - "avdArgs", - "avdEnv", - "avdLaunchTimeout", - "avdReadyTimeout", - "buildToolsVersion", - "bundleId", - "calendarAccessAuthorized", - "calendarFormat", - "chromeLoggingPrefs", - "chromeOptions", - "chromedriverArgs", - "chromedriverChromeMappingFile", - "chromedriverDisableBuildCheck", - "chromedriverExecutable", - "chromedriverExecutableDir", - "chromedriverPort", - "chromedriverPorts", - "chromedriverUseSystemExecutable", - "clearDeviceLogsOnStart", - "clearSystemFiles", - "commandTimeouts", - "connectHardwareKeyboard", - "customSSLCert", - "derivedDataPath", - "deviceName", - "disableAutomaticScreenshots", - "disableSuppressAccessibilityService", - "disableWindowAnimation", - "dontStopAppOnReset", - "enableAsyncExecuteFromHttps", - "enablePerformanceLogging", - "enableWebviewDetailsCollection", - "enforceAppInstall", - "enforceFreshSimulatorCreation", - "ensureWebviewsHavePages", - "extractChromeAndroidPackageFromContextName", - "forceAppLaunch", - "forceSimulatorSoftwareKeyboardPresence", - "fullContextList", - "fullReset", - "gpsEnabled", - "hideKeyboard", - "ignoreHiddenApiPolicyError", - "includeDeviceCapsToSessionInfo", - "includeSafariInWebviews", - "injectedImageProperties", - "intentAction", - "intentCategory", - "intentFlags", - "iosInstallPause", - "iosSimulatorLogsPredicate", - "isHeadless", - "keepKeyChains", - "keyAlias", - "keyPassword", - "keychainPassword", - "keychainPath", - "keychainsExcludePatterns", - "keystorePassword", - "keystorePath", - "language", - "launchWithIDB", - "locale", - "localeScript", - "localizableStringsDir", - "logcatFilterSpecs", - "logcatFormat", - "maxTypingFrequency", - "mjpegScreenshotUrl", - "mjpegServerPort", - "mockLocationApp", - "nativeWebScreenshot", - "nativeWebTap", - "nativeWebTapStrict", - "networkSpeed", - "newCommandTimeout", - "noReset", - "noSign", - "optionalIntentArguments", - "orientation", - "otherApps", - "permissions", - "platformVersion", - "prebuiltWDAPath", - "printPageSourceOnFindFailure", - "processArguments", - "recreateChromeDriverSessions", - "reduceMotion", - "reduceTransparency", - "remoteAdbHost", - "remoteAppsCacheLimit", - "resetLocationService", - "resetOnSessionStartOnly", - "resultBundlePath", - "resultBundleVersion", - "safariAllowPopups", - "safariGarbageCollect", - "safariGlobalPreferences", - "safariIgnoreFraudWarning", - "safariIgnoreWebHostnames", - "safariInitialUrl", - "safariLogAllCommunication", - "safariLogAllCommunicationHexDump", - "safariOpenLinksInBackground", - "safariSocketChunkSize", - "safariWebInspectorMaxFrameLength", - "scaleFactor", - "screenshotQuality", - "shouldTerminateApp", - "shouldUseSingletonTestManager", - "showChromedriverLog", - "showIOSLog", - "showXcodeLog", - "shutdownOtherSimulators", - "simpleIsVisibleCheck", - "simulatorDevicesSetPath", - "simulatorPasteboardAutomaticSync", - "simulatorStartupTimeout", - "simulatorTracePointer", - "simulatorWindowCenter", - "skipDeviceInitialization", - "skipLogCapture", - "skipLogcatCapture", - "skipServerInstallation", - "skipUnlock", - "suppressKillServer", - "systemPort", - "timeZone", - "udid", - "uiautomator2ServerInstallTimeout", - "uiautomator2ServerLaunchTimeout", - "uiautomator2ServerReadTimeout", - "uninstallOtherPackages", - "unlockKey", - "unlockStrategy", - "unlockSuccessTimeout", - "unlockType", - "updatedWDABundleId", - "useJSONSource", - "useKeystore", - "useNativeCachingStrategy", - "useNewWDA", - "usePrebuiltWDA", - "usePreinstalledWDA", - "useSimpleBuildTest", - "useXctestrunFile", - "userProfile", - "waitForIdleTimeout", - "waitForQuiescence", - "wdaBaseUrl", - "wdaConnectionTimeout", - "wdaEventloopIdleDelay", - "wdaLaunchTimeout", - "wdaLocalPort", - "wdaStartupRetries", - "wdaStartupRetryInterval", - "webDriverAgentUrl", - "webkitResponseTimeout", - "webviewConnectRetries", - "webviewConnectTimeout", - "webviewDevtoolsPort", - "xcodeConfigFile", - "xcodeOrgId", - "xcodeSigningId", - "commandTimeout", - "deviceOrientation", - "idleTimeout", - ] + # Check for unused applause options and remove them + for option, values in unused_applause_options: + for value in values: + if f"\"{option}\": \"{value}\"," in contents: + print(f"Removing unused option: {option} with value: {value} from {filepath}") + contents = contents.replace(f"\"{option}\": \"{value}\",", "") + elif f"\"{option}\" : \"{value}\"," in contents: + print(f"Removing unused option: {option} with value: {value} from {filepath}") + contents = contents.replace(f"\"{option}\" : \"{value}\",", "") + + + for capability, cap_scope in capabilities_to_update: + if f"\"{capability}\"" not in contents: + continue # Skip if capability is not present in the file + # Check if the capability is in the correct scope + if "all" in cap_scope: + contents = update_single_capability(filepath, contents, capability) + continue + + for scope in cap_scope: + + scopeparts = scope.split('_') + if len(scopeparts) != 2: + print(f"Warning: Scope {scope} for capability {capability} is not recognized. Skipping.") + continue + + driver_type = scopeparts[0] + driver_scope = scopeparts[1] + + # Check if the capability is in the correct driver type + if driver_type not in contents.lower(): + print(f"Driver type {driver_type} for capability {capability} not found in {filepath}. Skipping.") + continue + + if driver_scope == "all": + contents = update_single_capability(filepath, contents, capability) + continue + + if driver_scope in contents.lower(): + contents = update_single_capability(filepath, contents, capability) + continue + + print(f"Warning: Scope {driver_scope} for capability {capability} not found in {filepath}. Skipping.") - for capability in capabilities: - if f"\"{capability}\"" in contents: - print(f"Updating capability: {capability} in {filepath}") - # Replace the capability with its Appium v6.0.0 equivalent - contents =contents.replace(f"\"{capability}\"", f"\"appium:{capability}\"") with open(filepath, 'w') as outfile: outfile.write(contents) +def update_single_capability(filepath, contents, capability): + print(f"Updating capability: {capability} in {filepath}") + return contents.replace(f"\"{capability}\"", f"\"appium:{capability}\"") + # main execution starts here args_processed = 0