appium-proxy
appium-proxy
is a proxy for appium server that supports to keep the server alive for a long time. It is suitable for running test cases belong with one session id.
Table of Contents
Installation
$ npm install -g appium-proxy
Server flags
The real-url flag is required, this proxy will use this url as a destination.
Flag | Default | Description | Example |
---|---|---|---|
-a , --address |
0.0.0.0 | IP Address to listen on | --address 0.0.0.0 |
-p , --port |
9000 | port to listen on | --port 9000 |
--real-url |
required | Original URL of Appium | --real-url https://xyz@ondemand.saucelabs.com:443/wd/hub |
--command-timeout |
600 | Used to keep the server alive (in seconds) | --command-timeout 600 |
--delete-session |
true | Ignore a delete session request to keep server alive | --delete-session |
--capability-identify |
id | Identify which session will be used | --capability-identify id |
Use Cases
Setup a basic appium proxy
For example, you have a simple code like this:
String serverUrl = "https://tinonsoftware:123456789@ondemand.saucelabs.com:443/wd/hub"; DesiredCapabilities capabilities = new DesiredCapabilities();capabilities.; capabilities.;capabilities.;capabilities.; capabilities.; // you have to add this capability AppiumDriver<WebElement> driver = new AndroidDriver<WebElement>(new URL(serverUrl), capabilities);
First, you have to start the appium proxy with that server url.
$ appium-proxy --real-url "https://tinonsoftware:123456789@ondemand.saucelabs.com:443/wd/hub"
Secondly, replaced your appium url by "http://localhost:9000"
String serverUrl = "http://localhost:9000";
Setup to run parallel
Sometimes, you need to run a parallel execution. We provide a flag named capability-identify that can identify which the session which belongs to.
$ appium-proxy --real-url "https://tinonsoftware:123456789@ondemand.saucelabs.com:443/wd/hub" --capability-identify id
Now you can replace your url as "http://localhost:9000". Declared the first one:
DesiredCapabilities capabilities = new DesiredCapabilities();capabilities.; capabilities.;capabilities.;capabilities.; capabilities.; AppiumDriver<WebElement> driver1 = new AndroidDriver<WebElement>(new URL(serverUrl), capabilities);
Declared the second one:
DesiredCapabilities capabilities = new DesiredCapabilities();capabilities.; capabilities.;capabilities.;capabilities.; capabilities.; AppiumDriver<WebElement> driver2 = new AndroidDriver<WebElement>(new URL(serverUrl), capabilities);
To know which sessions are used please enter "http://localhost:9000/json"