Configure a device with a proxy
You can use Appium or Selenium WebDriver to configure a proxy on the remote Android or iOS device, at the start of your test.
This makes sure that all traffic on the device will go through the external proxy, which can be useful to do geolocation testing or latency testing.
desired_caps = {
'deviceName' => 'Galaxy S8',
'platformName' => 'Android',
'platformVersion' => '9.0',
'app' => 'https://testingbot.com/appium/sample.apk',
'realDevice' => true
}
# Set up the proxy settings
proxy = {
'proxyType' => 'manual', # Proxy type (manual or system)
'httpProxy' => 'http://your-proxy-server:8080', # Replace with your HTTP proxy URL
'sslProxy' => 'http://your-proxy-server:8080', # Replace with your SSL proxy URL
'noProxy' => 'localhost,127.0.0.1' # Optional: bypass proxy for specific hosts
}
# Add proxy to desired capabilities
desired_caps['proxy'] = proxy
# Initialize the Appium driver
driver = Appium::Driver.new({caps: desired_caps}, true)
DesiredCapabilities capabilities = new DesiredCapabilities();
// Set basic capabilities
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Galaxy S8");
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "9.0");
capabilities.setCapability(MobileCapabilityType.APP, "https://testingbot.com/appium/sample.apk");
capabilities.setCapability("realDevice", true);
// Set up proxy settings
Proxy proxy = new Proxy();
proxy.setHttpProxy("http://your-proxy-server:8080"); // Replace with your HTTP proxy URL
proxy.setSslProxy("http://your-proxy-server:8080"); // Replace with your SSL proxy URL
// Apply the proxy settings to the capabilities
capabilities.setCapability("proxy", proxy);
// Initialize the driver with TestingBot Appium server URL
URL appiumServerUrl = new URL("https://hub.testingbot.com/wd/hub");
RemoteWebDriver driver = new RemoteWebDriver(appiumServerUrl, capabilities);
$capabilities = array(
'app' => 'https://testingbot.com/appium/sample.apk',
'deviceName' => 'Galaxy S8',
'version' => '9.0',
'platformName' => 'Android',
'realDevice' => true,
'proxy' => array(
'proxyType' => 'manual', // Proxy type, "manual" for custom proxy settings
'httpProxy' => 'http://your-proxy-server:8080', // Replace with your HTTP proxy
'sslProxy' => 'http://your-proxy-server:8080', // Replace with your SSL proxy (HTTPS traffic)
'noProxy' => 'localhost,127.0.0.1' // Optional: addresses that should bypass the proxy
)
);
$web_driver = RemoteWebDriver::create('https://hub.testingbot.com/wd/hub', $capabilities, null, null, PROXY_URL, PROXY_PORT);
desired_caps = {
"deviceName": "Galaxy S8",
"platformName": "Android",
"platformVersion": "9.0",
"app": "https://testingbot.com/appium/sample.apk",
"realDevice": True,
"proxy": {
"proxyType": "manual", # Or "system" if you want to use system proxy
"httpProxy": "http://your-proxy-server:8080", # Replace with your proxy server
"sslProxy": "http://your-proxy-server:8080", # Replace with your proxy server for SSL
"noProxy": "localhost,127.0.0.1" # Optional: specify addresses to bypass the proxy
}
}
driver = webdriver.Remote(
command_executor="https://hub.testingbot.com/wd/hub",
desired_capabilities=desired_caps
)
const desiredCaps = {
'name': 'My First App Test',
'deviceName' : 'Galaxy S8',
'platformName': 'Android',
'version': '9.0',
'app' : 'https://testingbot.com/appium/sample.apk',
'realDevice': true,
'proxy': {
proxyType: 'manual',
httpProxy: 'http://proxy-server:8080', // Replace with your proxy server URL
sslProxy: 'http://proxy-server:8080', // If needed for SSL connections
noProxy: '' // You can define URLs to bypass the proxy
}
};
const driver = wd.promiseRemote("https://" + testingbotKey + ":" + testingbotSecret + "@hub.testingbot.com/wd/hub");
AppiumOptions caps = new AppiumOptions();
caps.AddAdditionalCapability("key", "");
caps.AddAdditionalCapability("secret", "");
caps.AddAdditionalCapability("deviceName", "Galaxy S10");
caps.AddAdditionalCapability("version", "10.0");
caps.AddAdditionalCapability("realDevice", true);
caps.AddAdditionalCapability("app", "https://testingbot.com/appium/sample.apk");
caps.platformName = "Android";
// Set up proxy using the Proxy class
Proxy proxy = new Proxy();
proxy.HttpProxy = "http://your-proxy-server:8080"; // Replace with your proxy URL
proxy.SslProxy = "http://your-proxy-server:8080"; // Replace with your proxy URL
proxy.NoProxy = "localhost,127.0.0.1"; // Optional: bypass proxy for specific addresses
// Apply the proxy to the Appium options
options.Proxy = proxy;