|
| 1 | +#!/usr/bin/env python3 |
| 2 | +import sys |
| 3 | +import os |
| 4 | + |
| 5 | +# Conversion script for migrating appium capabilities to use the appium prefix. This is required for the new version of appium |
| 6 | +# that is imported by the Java SDK 6.1.0 and later. |
| 7 | +def update_appium_capabilities(filepath): |
| 8 | + with open(filepath, 'r') as infile: |
| 9 | + contents = infile.read() |
| 10 | + capabilities = [ |
| 11 | + "adbExecTimeout", |
| 12 | + "adbPort", |
| 13 | + "absoluteWebLocations", |
| 14 | + "additionalWebviewBundleIds", |
| 15 | + "allowDelayAdb", |
| 16 | + "allowProvisioningDeviceRegistration", |
| 17 | + "allowTestPackages", |
| 18 | + "androidInstallTimeout", |
| 19 | + "app", |
| 20 | + "appActivity", |
| 21 | + "appInstallStrategy", |
| 22 | + "appPackage", |
| 23 | + "appPushTimeout", |
| 24 | + "appWaitActivity", |
| 25 | + "appWaitDuration", |
| 26 | + "appWaitForLaunch", |
| 27 | + "appWaitPackage", |
| 28 | + "autoAcceptAlerts", |
| 29 | + "autoFillPasswords", |
| 30 | + "autoGrantPermissions", |
| 31 | + "autoLaunch", |
| 32 | + "autoWebview", |
| 33 | + "autoWebviewName", |
| 34 | + "autoWebviewTimeout", |
| 35 | + "automationName", |
| 36 | + "avd", |
| 37 | + "avdArgs", |
| 38 | + "avdEnv", |
| 39 | + "avdLaunchTimeout", |
| 40 | + "avdReadyTimeout", |
| 41 | + "buildToolsVersion", |
| 42 | + "bundleId", |
| 43 | + "calendarAccessAuthorized", |
| 44 | + "calendarFormat", |
| 45 | + "chromeLoggingPrefs", |
| 46 | + "chromeOptions", |
| 47 | + "chromedriverArgs", |
| 48 | + "chromedriverChromeMappingFile", |
| 49 | + "chromedriverDisableBuildCheck", |
| 50 | + "chromedriverExecutable", |
| 51 | + "chromedriverExecutableDir", |
| 52 | + "chromedriverPort", |
| 53 | + "chromedriverPorts", |
| 54 | + "chromedriverUseSystemExecutable", |
| 55 | + "clearDeviceLogsOnStart", |
| 56 | + "clearSystemFiles", |
| 57 | + "commandTimeouts", |
| 58 | + "connectHardwareKeyboard", |
| 59 | + "customSSLCert", |
| 60 | + "derivedDataPath", |
| 61 | + "deviceName", |
| 62 | + "disableAutomaticScreenshots", |
| 63 | + "disableSuppressAccessibilityService", |
| 64 | + "disableWindowAnimation", |
| 65 | + "dontStopAppOnReset", |
| 66 | + "enableAsyncExecuteFromHttps", |
| 67 | + "enablePerformanceLogging", |
| 68 | + "enableWebviewDetailsCollection", |
| 69 | + "enforceAppInstall", |
| 70 | + "enforceFreshSimulatorCreation", |
| 71 | + "ensureWebviewsHavePages", |
| 72 | + "extractChromeAndroidPackageFromContextName", |
| 73 | + "forceAppLaunch", |
| 74 | + "forceSimulatorSoftwareKeyboardPresence", |
| 75 | + "fullContextList", |
| 76 | + "fullReset", |
| 77 | + "gpsEnabled", |
| 78 | + "hideKeyboard", |
| 79 | + "ignoreHiddenApiPolicyError", |
| 80 | + "includeDeviceCapsToSessionInfo", |
| 81 | + "includeSafariInWebviews", |
| 82 | + "injectedImageProperties", |
| 83 | + "intentAction", |
| 84 | + "intentCategory", |
| 85 | + "intentFlags", |
| 86 | + "iosInstallPause", |
| 87 | + "iosSimulatorLogsPredicate", |
| 88 | + "isHeadless", |
| 89 | + "keepKeyChains", |
| 90 | + "keyAlias", |
| 91 | + "keyPassword", |
| 92 | + "keychainPassword", |
| 93 | + "keychainPath", |
| 94 | + "keychainsExcludePatterns", |
| 95 | + "keystorePassword", |
| 96 | + "keystorePath", |
| 97 | + "language", |
| 98 | + "launchWithIDB", |
| 99 | + "locale", |
| 100 | + "localeScript", |
| 101 | + "localizableStringsDir", |
| 102 | + "logcatFilterSpecs", |
| 103 | + "logcatFormat", |
| 104 | + "maxTypingFrequency", |
| 105 | + "mjpegScreenshotUrl", |
| 106 | + "mjpegServerPort", |
| 107 | + "mockLocationApp", |
| 108 | + "nativeWebScreenshot", |
| 109 | + "nativeWebTap", |
| 110 | + "nativeWebTapStrict", |
| 111 | + "networkSpeed", |
| 112 | + "newCommandTimeout", |
| 113 | + "noReset", |
| 114 | + "noSign", |
| 115 | + "optionalIntentArguments", |
| 116 | + "orientation", |
| 117 | + "otherApps", |
| 118 | + "permissions", |
| 119 | + "platformVersion", |
| 120 | + "prebuiltWDAPath", |
| 121 | + "printPageSourceOnFindFailure", |
| 122 | + "processArguments", |
| 123 | + "recreateChromeDriverSessions", |
| 124 | + "reduceMotion", |
| 125 | + "reduceTransparency", |
| 126 | + "remoteAdbHost", |
| 127 | + "remoteAppsCacheLimit", |
| 128 | + "resetLocationService", |
| 129 | + "resetOnSessionStartOnly", |
| 130 | + "resultBundlePath", |
| 131 | + "resultBundleVersion", |
| 132 | + "safariAllowPopups", |
| 133 | + "safariGarbageCollect", |
| 134 | + "safariGlobalPreferences", |
| 135 | + "safariIgnoreFraudWarning", |
| 136 | + "safariIgnoreWebHostnames", |
| 137 | + "safariInitialUrl", |
| 138 | + "safariLogAllCommunication", |
| 139 | + "safariLogAllCommunicationHexDump", |
| 140 | + "safariOpenLinksInBackground", |
| 141 | + "safariSocketChunkSize", |
| 142 | + "safariWebInspectorMaxFrameLength", |
| 143 | + "scaleFactor", |
| 144 | + "screenshotQuality", |
| 145 | + "shouldTerminateApp", |
| 146 | + "shouldUseSingletonTestManager", |
| 147 | + "showChromedriverLog", |
| 148 | + "showIOSLog", |
| 149 | + "showXcodeLog", |
| 150 | + "shutdownOtherSimulators", |
| 151 | + "simpleIsVisibleCheck", |
| 152 | + "simulatorDevicesSetPath", |
| 153 | + "simulatorPasteboardAutomaticSync", |
| 154 | + "simulatorStartupTimeout", |
| 155 | + "simulatorTracePointer", |
| 156 | + "simulatorWindowCenter", |
| 157 | + "skipDeviceInitialization", |
| 158 | + "skipLogCapture", |
| 159 | + "skipLogcatCapture", |
| 160 | + "skipServerInstallation", |
| 161 | + "skipUnlock", |
| 162 | + "suppressKillServer", |
| 163 | + "systemPort", |
| 164 | + "timeZone", |
| 165 | + "udid", |
| 166 | + "uiautomator2ServerInstallTimeout", |
| 167 | + "uiautomator2ServerLaunchTimeout", |
| 168 | + "uiautomator2ServerReadTimeout", |
| 169 | + "uninstallOtherPackages", |
| 170 | + "unlockKey", |
| 171 | + "unlockStrategy", |
| 172 | + "unlockSuccessTimeout", |
| 173 | + "unlockType", |
| 174 | + "updatedWDABundleId", |
| 175 | + "useJSONSource", |
| 176 | + "useKeystore", |
| 177 | + "useNativeCachingStrategy", |
| 178 | + "useNewWDA", |
| 179 | + "usePrebuiltWDA", |
| 180 | + "usePreinstalledWDA", |
| 181 | + "useSimpleBuildTest", |
| 182 | + "useXctestrunFile", |
| 183 | + "userProfile", |
| 184 | + "waitForIdleTimeout", |
| 185 | + "waitForQuiescence", |
| 186 | + "wdaBaseUrl", |
| 187 | + "wdaConnectionTimeout", |
| 188 | + "wdaEventloopIdleDelay", |
| 189 | + "wdaLaunchTimeout", |
| 190 | + "wdaLocalPort", |
| 191 | + "wdaStartupRetries", |
| 192 | + "wdaStartupRetryInterval", |
| 193 | + "webDriverAgentUrl", |
| 194 | + "webkitResponseTimeout", |
| 195 | + "webviewConnectRetries", |
| 196 | + "webviewConnectTimeout", |
| 197 | + "webviewDevtoolsPort", |
| 198 | + "xcodeConfigFile", |
| 199 | + "xcodeOrgId", |
| 200 | + "xcodeSigningId" |
| 201 | + ] |
| 202 | + |
| 203 | + for capability in capabilities: |
| 204 | + if f"\"{capability}\"" in contents: |
| 205 | + print(f"Updating capability: {capability} in {filepath}") |
| 206 | + # Replace the capability with its Appium v6.0.0 equivalent |
| 207 | + contents =contents.replace(f"\"{capability}\"", f"\"appium:{capability}\"") |
| 208 | + with open(filepath, 'w') as outfile: |
| 209 | + outfile.write(contents) |
| 210 | + |
| 211 | + |
| 212 | +# main execution starts here |
| 213 | +args_processed = 0 |
| 214 | +for filepath in sys.argv[1:]: |
| 215 | + args_processed = args_processed + 1 |
| 216 | + if os.path.isfile(filepath) and filepath[-5:] == '.json': |
| 217 | + update_appium_capabilities(filepath) |
| 218 | + elif os.path.isdir(filepath): |
| 219 | + for root, dirs, files in os.walk(filepath): |
| 220 | + for path in files: |
| 221 | + if path[-5:] == '.json': |
| 222 | + print("Processing file: " + os.path.join(root, path)) |
| 223 | + update_appium_capabilities(os.path.join(root, path)) |
| 224 | + else: |
| 225 | + print(filepath + ' is not a valid json file or directory.') |
| 226 | + |
| 227 | +if (args_processed == 0): |
| 228 | + print("Usage: %s <path-to-directory>]+") |
| 229 | + print("Converts files from ") |
| 230 | + print(" <path-to-driver> : relative or absolute path to a directory with .json or pom.xml files to convert") |
0 commit comments