|
| 1 | +# Sauce Labs Troubleshooting Guide |
| 2 | + |
| 3 | +This guide helps resolve common Sauce Labs infrastructure errors when running CodeceptJS tests with Appium. |
| 4 | + |
| 5 | +## Common Error: "Infrastructure Error -- The Sauce VMs failed to start the browser or device" |
| 6 | + |
| 7 | +This error typically occurs due to: |
| 8 | + |
| 9 | +### 1. Missing or Invalid Credentials |
| 10 | +```bash |
| 11 | +# Set these environment variables before running tests |
| 12 | +export SAUCE_USERNAME="your_sauce_username" |
| 13 | +export SAUCE_ACCESS_KEY="your_sauce_access_key" |
| 14 | +``` |
| 15 | + |
| 16 | +### 2. Outdated Platform/Device Combinations |
| 17 | +The error often occurs when requesting deprecated or unavailable devices/OS versions. |
| 18 | + |
| 19 | +**Updated Android Configuration:** |
| 20 | +```javascript |
| 21 | +{ |
| 22 | + helpers: { |
| 23 | + Appium: { |
| 24 | + host: 'ondemand.us-west-1.saucelabs.com', |
| 25 | + port: 443, |
| 26 | + protocol: 'https', |
| 27 | + user: process.env.SAUCE_USERNAME, |
| 28 | + key: process.env.SAUCE_ACCESS_KEY, |
| 29 | + desiredCapabilities: { |
| 30 | + 'sauce:options': { |
| 31 | + appiumVersion: '2.0.0', |
| 32 | + name: 'Your Test Name', |
| 33 | + build: process.env.BUILD_NUMBER || 'local-build', |
| 34 | + tags: ['codeceptjs', 'appium', 'android'], |
| 35 | + recordVideo: false, |
| 36 | + recordScreenshots: false, |
| 37 | + idleTimeout: 300, |
| 38 | + newCommandTimeout: 300, |
| 39 | + }, |
| 40 | + browserName: '', |
| 41 | + platformName: 'Android', |
| 42 | + platformVersion: '12.0', // Use recent versions |
| 43 | + deviceName: 'Google Pixel 6 GoogleAPI Emulator', |
| 44 | + automationName: 'UiAutomator2', |
| 45 | + autoGrantPermissions: true, |
| 46 | + noReset: true, |
| 47 | + app: 'sauce-storage:your-app.apk' |
| 48 | + } |
| 49 | + } |
| 50 | + } |
| 51 | +} |
| 52 | +``` |
| 53 | + |
| 54 | +**Updated iOS Configuration:** |
| 55 | +```javascript |
| 56 | +{ |
| 57 | + helpers: { |
| 58 | + Appium: { |
| 59 | + host: 'ondemand.us-west-1.saucelabs.com', |
| 60 | + port: 443, |
| 61 | + protocol: 'https', |
| 62 | + user: process.env.SAUCE_USERNAME, |
| 63 | + key: process.env.SAUCE_ACCESS_KEY, |
| 64 | + desiredCapabilities: { |
| 65 | + 'sauce:options': { |
| 66 | + appiumVersion: '2.0.0', |
| 67 | + name: 'Your iOS Test', |
| 68 | + build: process.env.BUILD_NUMBER || 'local-build', |
| 69 | + tags: ['codeceptjs', 'appium', 'ios'], |
| 70 | + recordVideo: false, |
| 71 | + recordScreenshots: false, |
| 72 | + idleTimeout: 300, |
| 73 | + newCommandTimeout: 300, |
| 74 | + }, |
| 75 | + browserName: '', |
| 76 | + platformName: 'iOS', |
| 77 | + platformVersion: '16.0', // Use recent versions |
| 78 | + deviceName: 'iPhone 14 Simulator', |
| 79 | + automationName: 'XCUITest', |
| 80 | + autoAcceptAlerts: true, |
| 81 | + noReset: true, |
| 82 | + app: 'sauce-storage:your-ios-app.ipa' |
| 83 | + } |
| 84 | + } |
| 85 | + } |
| 86 | +} |
| 87 | +``` |
| 88 | + |
| 89 | +### 3. Regional Endpoint Issues |
| 90 | +Use specific regional endpoints instead of the generic one: |
| 91 | +- US West: `ondemand.us-west-1.saucelabs.com` |
| 92 | +- US East: `ondemand.us-east-1.saucelabs.com` |
| 93 | +- EU: `ondemand.eu-central-1.saucelabs.com` |
| 94 | + |
| 95 | +### 4. App Upload Issues |
| 96 | +Ensure your app is properly uploaded to Sauce Storage: |
| 97 | +```bash |
| 98 | +# Upload app to Sauce Labs |
| 99 | +curl -u "$SAUCE_USERNAME:$SAUCE_ACCESS_KEY" \ |
| 100 | + -X POST "https://api.us-west-1.saucelabs.com/rest/v1/storage/upload" \ |
| 101 | + -H "Content-Type: application/octet-stream" \ |
| 102 | + --data-binary @your-app.apk |
| 103 | +``` |
| 104 | + |
| 105 | +### 5. Capability Validation |
| 106 | +Before running tests, validate your capabilities using Sauce Labs Platform Configurator: |
| 107 | +https://saucelabs.com/platform/platform-configurator |
| 108 | + |
| 109 | +### 6. Alternative Workarounds |
| 110 | + |
| 111 | +**Local Testing Fallback:** |
| 112 | +```javascript |
| 113 | +const sauceConfig = { |
| 114 | + // Sauce Labs configuration |
| 115 | +}; |
| 116 | + |
| 117 | +const localConfig = { |
| 118 | + host: 'localhost', |
| 119 | + port: 4723, |
| 120 | + protocol: 'http', |
| 121 | + desiredCapabilities: { |
| 122 | + platformName: 'Android', |
| 123 | + platformVersion: '11.0', |
| 124 | + deviceName: 'Android Emulator', |
| 125 | + automationName: 'UiAutomator2', |
| 126 | + app: '/path/to/your/app.apk' |
| 127 | + } |
| 128 | +}; |
| 129 | + |
| 130 | +// Use local config if Sauce Labs credentials are missing |
| 131 | +const config = (process.env.SAUCE_USERNAME && process.env.SAUCE_ACCESS_KEY) |
| 132 | + ? sauceConfig |
| 133 | + : localConfig; |
| 134 | +``` |
| 135 | + |
| 136 | +### 7. Debugging Steps |
| 137 | + |
| 138 | +1. **Check Sauce Labs service status:** |
| 139 | + ```bash |
| 140 | + curl -s "https://saucelabs.com/rest/v1/info/status" |
| 141 | + ``` |
| 142 | + |
| 143 | +2. **Verify account limits:** |
| 144 | + - Check concurrent session limits |
| 145 | + - Verify account is not suspended |
| 146 | + - Ensure sufficient credits/minutes |
| 147 | + |
| 148 | +3. **Test with basic capabilities:** |
| 149 | + Start with minimal capabilities and add complexity gradually. |
| 150 | + |
| 151 | +4. **Monitor Sauce Labs dashboard:** |
| 152 | + Check real-time test execution in the Sauce Labs dashboard for detailed error messages. |
| 153 | + |
| 154 | +### 8. Best Practices |
| 155 | + |
| 156 | +- Use HTTPS protocol for better security |
| 157 | +- Set appropriate timeouts (300+ seconds for mobile tests) |
| 158 | +- Use specific device names rather than generic ones |
| 159 | +- Keep platform versions current (within 2-3 major versions) |
| 160 | +- Use `sauce:options` for Sauce Labs specific configurations |
| 161 | +- Enable `noReset: true` to speed up test execution |
| 162 | +- Set meaningful test names and builds for better organization |
| 163 | + |
| 164 | +### 9. Contact Support |
| 165 | + |
| 166 | +If issues persist after following this guide: |
| 167 | +- Check Sauce Labs status page: https://status.saucelabs.com/ |
| 168 | +- Contact Sauce Labs support with your session ID and error details |
| 169 | +- Consider using alternative cloud providers (BrowserStack, etc.) |
0 commit comments