11# Requirements
2- - Installed Node.js 7 or greater.
2+ - Installed Node.js 7 or greater.
33
4- - At least an appium server instance installed via __ npm__ .
4+ - At least an appium server instance installed via __ npm__ .
55
66# The basic principle.
77
@@ -10,7 +10,7 @@ It works the similar way as common [ChromeDriver](https://seleniumhq.github.io/s
1010# How to prepare the local service before the starting
1111
1212
13- ## If there is no specific parameters then
13+ ## If there is no specific parameters then
1414
1515``` java
1616 import io.appium.java_client.service.local.AppiumDriverLocalService ;
@@ -20,7 +20,7 @@ It works the similar way as common [ChromeDriver](https://seleniumhq.github.io/s
2020 service. start();
2121 ...
2222 service. stop();
23- ```
23+ ```
2424
2525### FYI
2626
@@ -32,20 +32,23 @@ AppiumDriverLocalService service = AppiumDriverLocalService.buildDefaultService(
3232
3333It is more usual for UNIX/LINUX-like OS's. Also there are situations when should be used an another Node.JS instance, e.g. the instance which is installed in the directory that differs from one defined at the PATH environmental variable. The same may be true for Appium node server (it is related to _ appium.js_ file (v <= 1.4.16) and _ main.js_ (v >= 1.5.0)).
3434
35- At this case user is able to set up values of the ** NODE_BINARY_PATH** (The environmental variable used to define the path to executable NodeJS file (node.exe for WIN and node for Linux/MacOS X)) and the ** APPIUM_BINARY_PATH** (The environmental variable used to define the path to executable appium.js (1.4.x and lower) or main.js (1.5.x and higher)) environmental variables/system properties. Also it is possible to define these values programmatically:
35+ At this case user is able to set up values of the ** NODE_BINARY_PATH** (The environmental variable used to define the path to executable NodeJS file (node.exe for WIN and node for Linux/MacOS X)) and the ** APPIUM_BINARY_PATH** (The environmental variable used to define the path to executable appium.js (1.4.x and lower) or main.js (1.5.x and higher)) environmental variables/system properties. Also it is possible to define these values programmatically:
3636
3737``` java
38+ import io.appium.java_client.service.local.AppiumDriverLocalService ;
39+ import io.appium.java_client.service.local.AppiumServiceBuilder ;
40+
3841// appium.node.js.exec.path
39- System . setProperty(AppiumServiceBuilder . NODE_PATH ,
42+ System . setProperty(AppiumServiceBuilder . NODE_PATH,
4043" the path to the desired node.js executable" );
4144
42- System . setProperty(AppiumServiceBuilder . APPIUM_PATH ,
45+ System . setProperty(AppiumServiceBuilder . APPIUM_PATH,
4346" the path to the desired appium.js or main.js" );
4447
4548AppiumDriverLocalService service = AppiumDriverLocalService . buildDefaultService();
4649```
4750
48- ## If there should be non default parameters specified then
51+ ## If there should be non default parameters specified then
4952
5053``` java
5154import io.appium.java_client.service.local.AppiumDriverLocalService ;
@@ -57,9 +60,9 @@ AppiumDriverLocalService service = AppiumDriverLocalService.
5760buildService(new AppiumServiceBuilder ().
5861withArgument(GeneralServerFlag . TEMP_DIRECTORY ,
5962 " The_path_to_the_temporary_directory" ));
60- ```
63+ ```
6164
62- or
65+ or
6366
6467``` java
6568import io.appium.java_client.service.local.AppiumDriverLocalService ;
@@ -70,64 +73,64 @@ import io.appium.java_client.service.local.flags.GeneralServerFlag;
7073AppiumDriverLocalService service = new AppiumServiceBuilder ().
7174withArgument(GeneralServerFlag . TEMP_DIRECTORY ,
7275 " The_path_to_the_temporary_directory" ). build();
73- ```
76+ ```
7477
7578Lists of available server side flags are here:
7679
7780- io.appium.java_client.service.local.flags.GeneralServerFlag;
7881- io.appium.java_client.service.local.flags.AndroidServerFlag;
7982- io.appium.java_client.service.local.flags.IOSServerFlag
8083
81-
84+
8285## Which parameters also can be defined
8386
8487- If it is necessary to define some specific port or any free port
8588
8689``` java
8790new AppiumServiceBuilder (). usingPort(4000 );
88- ```
91+ ```
8992
90- or
93+ or
9194
9295``` java
9396new AppiumServiceBuilder (). usingAnyFreePort();
94- ```
97+ ```
9598
9699- If it is necessary to use another IP address
97100
98101``` java
99102new AppiumServiceBuilder (). withIPAddress(" 127.0.0.1" );
100- ```
103+ ```
101104
102105- If it is necessary to define output log file
103106
104107``` java
105- import java.io.File ;
108+ import java.io.File ;
106109 ...
107110
108111new AppiumServiceBuilder (). withLogFile(logFile);
109- ```
112+ ```
110113
111114- If it is necessary to define another Node.js executable file
112115
113116``` java
114117import java.io.File ;
115-
118+
116119...
117120
118121new AppiumServiceBuilder (). usingDriverExecutable(nodeJSExecutable);
119- ```
122+ ```
120123
121124- If it is necessary to define another appium.js/main.js file
122125
123126``` java
124127import java.io.File ;
125-
128+
126129...
127- // appiumJS is the full or relative path to
130+ // appiumJS is the full or relative path to
128131// the appium.js (v<=1.4.16) or main.js (v>=1.5.0)
129132new AppiumServiceBuilder (). withAppiumJS(new File (appiumJS));
130- ```
133+ ```
131134
132135- It is possible to define server capabilities (node server v >= 1.5.0)
133136
@@ -152,39 +155,39 @@ serverCapabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emul
152155serverCapabilities. setCapability(MobileCapabilityType . FULL_RESET , true );
153156serverCapabilities. setCapability(MobileCapabilityType . NEW_COMMAND_TIMEOUT , 60 );
154157serverCapabilities. setCapability(MobileCapabilityType . APP , app. getAbsolutePath());
155- serverCapabilities. setCapability(AndroidMobileCapabilityType . CHROMEDRIVER_EXECUTABLE ,
158+ serverCapabilities. setCapability(AndroidMobileCapabilityType . CHROMEDRIVER_EXECUTABLE ,
156159chrome. getAbsolutePath()); // this capability set can be used for all cases
157160
158161AppiumServiceBuilder builder = new AppiumServiceBuilder ().
159162withCapabilities(serverCapabilities);
160163AppiumDriverLocalService service = builder. build();
161164
162165DesiredCapabilities clientCapabilities = new DesiredCapabilities ();
163- clientCapabilities. setCapability(AndroidMobileCapabilityType . APP_PACKAGE ,
166+ clientCapabilities. setCapability(AndroidMobileCapabilityType . APP_PACKAGE ,
164167" io.appium.android.apis" );
165- clientCapabilities. setCapability(AndroidMobileCapabilityType . APP_ACTIVITY ,
168+ clientCapabilities. setCapability(AndroidMobileCapabilityType . APP_ACTIVITY ,
166169" .view.WebView1" );
167170```
168171
169172then
170173
171174``` java
172- AndroidDriver<MobileElement > driver =
175+ AndroidDriver<MobileElement > driver =
173176new AndroidDriver<> (service, clientCapabilities);
174177```
175178
176- or
179+ or
177180
178181``` java
179- AndroidDriver<MobileElement > driver =
182+ AndroidDriver<MobileElement > driver =
180183new AndroidDriver<> (builder, clientCapabilities);
181184```
182185
183- or
186+ or
184187
185188``` java
186189service. start();
187- AndroidDriver<MobileElement > driver =
190+ AndroidDriver<MobileElement > driver =
188191new AndroidDriver<> (service. getUrl(), clientCapabilities);
189192```
190193
@@ -219,7 +222,7 @@ public AndroidDriver(org.openqa.selenium.remote.http.HttpClient.Factory httpClie
219222 org.openqa.selenium. Capabilities desiredCapabilities)
220223
221224public AndroidDriver(org.openqa.selenium. Capabilities desiredCapabilities)
222- ```
225+ ```
223226
224227``` java
225228public IOSDriver(URL remoteAddress,
@@ -247,20 +250,20 @@ public IOSDriver(org.openqa.selenium.remote.http.HttpClient.Factory httpClientFa
247250 org.openqa.selenium. Capabilities desiredCapabilities)
248251
249252public IOSDriver(org.openqa.selenium. Capabilities desiredCapabilities)
250- ```
253+ ```
251254
252255An instance of __ AppiumDriverLocalService__ which has passed through constructors will be stopped when
253256
254257``` java
255258 driver. quit();
256- ```
259+ ```
257260
258261If it is necessary to keep the service alive during a long time then something like that is available
259262
260263``` java
261264 service. start();
262-
265+
263266 ....
264267
265268 new IOSDriver<MobileElement > (service. getUrl(), capabilities)
266- ```
269+ ```
0 commit comments