Launching and stopping appium server programmtically


#183

wonder if you have udid why you need set any device name… try without it.
also real reason in logs is - [debug] [XCUITest] Error: Could not get Xcode version. /Library/Developer/Info.plist does not exist on disk.


#185

Hey! I could solve this problem by adding /usr/bin:/usr/local/bin in my eclipse path variable and that solved this problem. But again I have an issue. So, when I start appium and my test run completes, after that I am not getting any testng logs. I mean the summary after test run from testng is missing in my logs. Any ideas how to resolve it. So the following summary is missing

===============================================
Default test
Tests run: 1, Failures: 0, Skips: 0

===============================================
Default suite
Total tests run: 1, Failures: 0, Skips: 0

[TestNG] Time taken by [email protected]: 27 ms
[TestNG] Time taken by [email protected]: 6 ms
[TestNG] Time taken by [email protected]: 5 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 0 ms
[TestNG] Time taken by [email protected]: 58 ms
[TestNG] Time taken by [email protected]: 4 ms


#186

Appium starts and stops @ [Appium] Appium REST http interface listener started on 0.0.0.0:4723

how do i move further to
[HTTP] --> POST /wd/hub/session {“desiredCapabilities”:{“app”:"/Users/vikumar/Desktop/ShareConnect.zip",“platformVersion”:“9.3”,“automationName”:“XCUITest”,“platformName”:“iOS”,“udid”:“dd5287b0c2c5c9a86b3144e5f6dbaa646744b835”,“deviceName”:“iPad”,“fullReset”:true}}

below is my command in jenkins(batch file)

this is my command
/usr/local/bin/node /Applications/Appium.app/Contents/Resources/node_modules/appium/build/lib/main.js --address 0.0.0.0 --port 4723/wd/hub --app /Users/Shared/Jenkins/Home/jobs/MMLocalProject/workspace/src/T/result/MeasuringMaster.app --command-timeout 200000


#187

[​] $ /bin/sh -xe /Users/Shared/Jenkins/tmp/hudson8130735449869040556.sh

  • cd /Users/Shared/Jenkins/Home/jobs/MMLocalProject/workspace/
  • chmod g+w+x appium.sh
  • sh appium.sh
    [Appium] Welcome to Appium v1.5.3
    [Appium] Non-default server args:
    [Appium] defaultCommandTimeout: 200000
    [Appium] app: ‘/Users/Shared/Jenkins/Home/jobs/MMLocalProject/workspace/src/T/result/MeasuringMaster.app’
    [Appium] Deprecated server args:
    [Appium] --app => --default-capabilities ‘{“app”:"/Users/Shared/Jenkins/Home/jobs/MMLocalProject/workspace/src/T/result/MeasuringMaster.app"}’
    [Appium] Default capabilities, which will be added to each request unless overridden by desired capabilities:
    [Appium] app: ‘/Users/Shared/Jenkins/Home/jobs/MMLocalProject/workspace/src/T/result/MeasuringMaster.app’
    [Appium] Appium REST http interface listener started on 0.0.0.0:4723

#188

Can anybody tell me how to pas the directory in as file string for mac ? i have tried diffrent ways but could not get it done.

1: private static String APPIUMSERVERSTART = “/bin/sh /Applications/Appium.app/Contents/Resources”;
2: private static String APPIUMSERVERSTART="/Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium.js";
3: private static String APPIUMSERVERSTART = "/bin/sh /Applications/Appium.app/Contents/Resources/node/bin/node /Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium.js " ;
and passed to
File file = new (APPIUMSERVERSTART);
AppiumServer appiumServer = new AppiumServer(file, serverArguments);

but every time it adds /node/bin/node at the end of path and says can not find directory. I am using macOS. Any help would be appreciated.
@Hassan_Radi @Nitinvermaa1 @tovaibhav1 @slipy12


#189

you need to create appium driver like this:
AppiumDriverLocalService appiumDriver = null;
appiumDriver = AppiumDriverLocalService.buildService(new AppiumServiceBuilder()
.withIPAddress(“127.0.0.1”)
.usingPort(port)
.withArgument(AndroidServerFlag.BOOTSTRAP_PORT_NUMBER, String.valueOf(bpPort))
.withLogFile(log));

    Field streamsField = null;
    Field streamField = null;

    try {
        streamField = AppiumDriverLocalService.class.getDeclaredField("stream");
        streamField.setAccessible(true);
        streamsField = Class.forName("io.appium.java_client.service.local.ListOutputStream").getDeclaredField("streams");
        streamsField.setAccessible(true);
    } catch (ClassNotFoundException | NoSuchFieldException e) {
        e.printStackTrace();
    }
    try {
        ((ArrayList<OutputStream>) streamsField.get(streamField.get(appiumDriver))).clear(); // remove System.out logging
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }

    appiumDriver.start();

and then you can create android driver using same port like this:

capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, deviceManager.getDeviceName());
capabilities.setCapability(MobileCapabilityType.UDID, deviceManager.getDeviceUdid());
capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 60 * 30);
capabilities.setCapability(MobileCapabilityType.NO_RESET, true);
capabilities.setCapability(MobileCapabilityType.FULL_RESET, false);
capabilities.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, currentPackageName);
capabilities.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, currentActivityName);

    if (apk!= null){
        capabilities.setCapability(MobileCapabilityType.APP, apk.getAbsolutePath());
    }

    URL serverAddress = new URL("http://127.0.0.1:" + port + "/wd/hub");
    androidDriver = new AndroidDriver(serverAddress , capabilities);

In this way, you can create appium + android drivers for each device. I you are running on multiple devices, you can create one for each of them and your tests will run on all devices


Not able to launch Appium 1.5.3 from java code on MAC
#190

For anybody reading this who happens to be using npm (node/js/typescript), I’ve created a module called appium-controller that starts and stops appium in the background programmatically (mac or windows) and solves the issues mentioned throughout. Appium logs are stored as well.


#191

Watch a video to explain server start and stop code https://youtu.be/uA8x3geLanA


#192

Hi All,
I’m facing the below exception with Appium-Desktop v1.3.2 (downloaded from appium.io), and trying to connect to appium server but not connecting to server. pls let me know the issue

in the latest version of Appium-Desktop do we need to provide main.js or appium.js file in the commandLineArgument. i tried both but still giving the error.
============================Code i’ve used==================

System.out.println(“Starting appium server”);
/CommandLine cmd = new CommandLine(“cmd”);
cmd.addArgument(“cmd”);
cmd.addArgument("/C");
/
/* cmd.addArgument(“C:\Users\satheeshnukala\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\lib\appium.js”); // commented the appium.js and used main.js file */
CommandLine cmd = new CommandLine(“C:\Program Files\nodejs\node.exe”);
//cmd.addArgument(“C:\Program Files\nodejs\node.exe”);
cmd.addArgument(“C:\Users\satheeshnukala\AppData\Local\Programs\appium-desktop\resources\app\main.js”);
cmd.addArgument("–address");
cmd.addArgument(“127.0.0.1”);
cmd.addArgument("–port");
cmd.addArgument(“4723”);
cmd.addArgument("–no-reset",true);
cmd.addArgument("–full-reset",false);
cmd.addArgument("–log");
cmd.addArgument(“C:\Users\satheeshnukala\workspace\AppiumTest\ConsoleLogs\AppiumConsoleLogs.txt”);

	DefaultExecuteResultHandler handler = new DefaultExecuteResultHandler();
	DefaultExecutor executor = new DefaultExecutor();
	executor.setExitValue(1);
	try {
		executor.execute(cmd, handler);
		Thread.sleep(10000);
	} catch (IOException | InterruptedException e) {
		e.printStackTrace();
	}
	System.out.println("Started appium server");

==================Exception by using main.js===========================
Starting appium server
Started appium server
Step-1
Step-2
Error: Cannot find module ‘electron’
at Function.Module._resolveFilename (module.js:538:15)
at Function.Module._load (module.js:468:25)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at Object.module.exports.Object.defineProperty.value (C:\Users\satheeshnukala\AppData\Local\Programs\appium-desktop\resources\app\webpack:\external “electron”:1:1)
at webpack_require (C:\Users\satheeshnukala\AppData\Local\Programs\appium-desktop\resources\app\webpack:\webpack\bootstrap dfa496e38cddd9338602:19:1)
at Object. (C:\Users\satheeshnukala\AppData\Local\Programs\appium-desktop\resources\app\webpack:\app\main\main.development.js:1:1)
at webpack_require (C:\Users\satheeshnukala\AppData\Local\Programs\appium-desktop\resources\app\webpack:\webpack\bootstrap dfa496e38cddd9338602:19:1)
at Object. (C:\Users\satheeshnukala\AppData\Local\Programs\appium-desktop\resources\app\main.js:50:19)
at webpack_require (C:\Users\satheeshnukala\AppData\Local\Programs\appium-desktop\resources\app\webpack:\webpack\bootstrap dfa496e38cddd9338602:19:1)
Exception in thread “main” org.openqa.selenium.WebDriverException: Connection refused: connect
Build info: version: ‘3.9.1’, revision: ‘63f7b50’, time: ‘2018-02-07T22:42:28.403Z’
System info: host: ‘10INLPC0BS59M’, ip: ‘10.216.42.151’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_144’
Driver info: driver.version: AndroidDriver
at io.appium.java_client.remote.AppiumCommandExecutor.lambda$2(AppiumCommandExecutor.java:141)
at java.util.Optional.orElseGet(Optional.java:267)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:140)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:219)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:142)
at io.appium.java_client.DefaultGenericMobileDriver.(DefaultGenericMobileDriver.java:38)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:84)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:94)
at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:77)
at AppiumPackage.AppiumServerJava.startServer(AppiumServerJava.java:62)
at AppiumPackage.AppiumServerJava.main(AppiumServerJava.java:110)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:75)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:359)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:151)
at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:91)
at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:69)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:101)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:138)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:129)
… 12 more


#193

appium server can be started using below code, without any hardcoded values:

AppiumServiceBuilder builder = new AppiumServiceBuilder();
builder = new AppiumServiceBuilder();
builder.withIPAddress(“127.0.0.1”);
builder.usingAnyFreePort();
builder.withCapabilities(cap);
builder.withArgument(GeneralServerFlag.SESSION_OVERRIDE);
builder.withArgument(GeneralServerFlag.LOG_LEVEL, “error”);
AppiumDriverLocalService service = AppiumDriverLocalService.buildService(builder);
service.start();
String appiumServiceUrl = service.getUrl().toString();
driver = new AndroidDriver(new URL(appiumServiceUrl), cap);


#194

I am trying to start the appium server programmatically using ruby. for that I am using AfterConfifguration hook in Hooks file

AfterConfiguration do
_ exec ‘appium’_
_ end_

When i execute the above using this command ‘cucumber feature/signIn.feature’ command, appium server stars but not invoking the test cases.

Any idea ?
Please help me to do it in Mac using Ruby.

Appium server version: 1.8.0
Mac OS: 10.13
node: 6.11
Ruby: 2.5.1

Thanks in advance,


#195

You need to pass an instance of Cucumber::Cli::Configuration. See here for an example:

You may find it easier to just start Appium in a Before hook.


#196

Thanks for the reply Wreed. I am facing same problem even after passing config. Here is updated AfterConfiguration hook. I am providing log file along with this.

AfterConfiguration do |config|
system’appium’
end

poornimas-Mac-mini:AutomationScipts poornima$ cucumber features/01-SignIn.feature:7
/usr/local/lib/ruby/gems/2.5.0/gems/selenium-webdriver-3.11.0/lib/selenium/webdriver/common/interactions/pointer_actions.rb:21: warning: previous definition of DEFAULT_MOVE_DURATION w
as here
[Appium] Appium support for versions of node < 8 has been deprecated and will be removed in a future version. Please upgrade!
[Appium] Welcome to Appium v1.8.1
[Appium] Appium REST http interface listener started on 0.0.0.0:4723

If i Run same the code after starting appium server manually output goes like this.
poornimas-Mac-mini:AutomationScipts poornima$ cucumber features/01-SignIn.feature:7
/usr/local/lib/ruby/gems/2.5.0/gems/appium_lib_core-1.3.7/lib/appium_lib_core/common/base/bridge/w3c.rb:8: warning: already initialized constant Selenium::WebDriver::PointerActions::smiley:
EFAULT_MOVE_DURATION
/usr/local/lib/ruby/gems/2.5.0/gems/selenium-webdriver-3.11.0/lib/selenium/webdriver/common/interactions/pointer_actions.rb:21: warning: previous definition of DEFAULT_MOVE_DURATION w
as here
[Appium] Appium support for versions of node < 8 has been deprecated and will be removed in a future version. Please upgrade!
[Appium] Welcome to Appium v1.8.1
[HTTP] Could not start REST http interface listener. The requested port may already be in use. Please make sure there is no other instance of this server running already.
Fatal Error: listen EADDRINUSE 0.0.0.0:4723
at Object.exports._errnoException (util.js:1018:11)
at exports._exceptionWithHostPort (util.js:1041:20)
at Server._listen2 (net.js:1258:14)
at listen (net.js:1294:10)
at net.js:1404:9

at _combinedTickCallback (internal/process/next_tick.js:83:11)
at process._tickCallback (internal/process/next_tick.js:104:9)

Feature: As a user, I want to be able to sign in with my Fresenius user ID, so that I can access the Compass application on iOS, Android, and web platforms.

[DEPRECATION] Appium::Driver.new(opts) will not generate global driver by default.If you would like to generate the global driver dy default, please initialise driver with Appium::Dri
ver.new(opts, true)
Scenario: The user will be presented with a login screen where he can enter a username and password. # features/01-SignIn.f
eature:7
# Format: Given I launch the application “” in device “” with udid “” on wdaport “8100” and local port “4723”
Given I launch the application “compass.ipa” in device “iPhone” with udid “3fa1898388954983622d2764e219ffc5da7d067b” on wdaport “8100” and local port “4723” # features/step_defini
tions/steps.rb.rb:4
And I assert for identifier “signInLogoImageView” # features/step_defini
tions/steps.rb.rb:71
And I assert for identifier “signInUsernameTextField” # features/step_defini
tions/steps.rb.rb:71
And I assert for identifier “signInPasswordTextField” # features/step_defini
tions/steps.rb.rb:71
And I assert for identifier “signInForgotPasswordButton” # features/step_defini
tions/steps.rb.rb:71
And I assert for identifier “signInContactSupportButton” # features/step_defini
tions/steps.rb.rb:71
And I assert for identifier “signInButton” # features/step_defini
tions/steps.rb.rb:71

1 scenario (1 passed)
7 steps (7 passed)

On running same test without Afterconfiguration hook
poornimas-Mac-mini:AutomationScipts poornima$ cucumber features/01-SignIn.feature:7
/usr/local/lib/ruby/gems/2.5.0/gems/appium_lib_core-1.3.7/lib/appium_lib_core/common/base/bridge/w3c.rb:8: warning: already initialized constant Selenium::WebDriver::PointerActions::smiley:
EFAULT_MOVE_DURATION
/usr/local/lib/ruby/gems/2.5.0/gems/selenium-webdriver-3.11.0/lib/selenium/webdriver/common/interactions/pointer_actions.rb:21: warning: previous definition of DEFAULT_MOVE_DURATION w
as here
Feature: As a user, I want to be able to sign in with my Fresenius user ID, so that I can access the Compass application on iOS, Android, and web platforms.

[DEPRECATION] Appium::Driver.new(opts) will not generate global driver by default.If you would like to generate the global driver dy default, please initialise driver with Appium::Dri
ver.new(opts, true)
Scenario: The user will be presented with a login screen where he can enter a username and password. # features/01-SignIn.f
eature:7
# Format: Given I launch the application “” in device “” with udid “” on wdaport “8100” and local port “4723”
Given I launch the application “compass.ipa” in device “iPhone” with udid “3fa1898388954983622d2764e219ffc5da7d067b” on wdaport “8100” and local port “4723” # features/step_defini
tions/steps.rb.rb:4
And I assert for identifier “signInLogoImageView” # features/step_defini
tions/steps.rb.rb:71
And I assert for identifier “signInUsernameTextField” # features/step_defini
tions/steps.rb.rb:71
And I assert for identifier “signInPasswordTextField” # features/step_defini
tions/steps.rb.rb:71
And I assert for identifier “signInForgotPasswordButton” # features/step_defini
tions/steps.rb.rb:71
And I assert for identifier “signInContactSupportButton” # features/step_defini
tions/steps.rb.rb:71
And I assert for identifier “signInButton” # features/step_defini
tions/steps.rb.rb:71

1 scenario (1 passed)
7 steps (7 passed)
0m9.511s


#197

You may have missed this comment. I would advise not getting hung up on the semantics of Cucumber. It’s a good tool but ultimately you just need to get tests working. Try a Before hook. Personally, I have implemented this in env.rb as standalone code after importing my support Gems and initializing my settings.


#199

I don’t think it will help you much, but sure. We have a common Gem that we share with Android QE. It takes care of loading settings & such, creates capabilities and all that. All we really have to do from the local framework is use the Appium object we’ve created (‘apm’) and call the init_driver method to start the server:

# This is where Appium is initialized
begin
  # Initialize Appium
  apm.init_driver
# This is one of the only times I would rescue unknown exceptions.  We do so for debugging, and so
#  that we can report what exception was thrown in the logs.  Otherwise debugging can be a nightmare.
rescue Exception => e
  log.error "Failed initializing appium, exception class is #{e.class}"
  apm.close_driver
  raise e
end

I can’t publish our whole framework, but that is how we start Appium in env.rb. Although our code is probably a lot more complicated than the standard setup, it’s very robust, mature, and easy to use.

If you really want help with this, you should put the code you used in before hook and a log of what the failure is.


#200

How to stop the running server at the end of execution as i am able to run it successfully but is unable to close it.


#201

Here is solution for BDD framework written Ruby.

Starting the server:

AfterConfiguration do |config|
_ pid = spawn ‘appium --address 0.0.0.0 --port 4723’_
_ Process.detach(pid)_
_ sleep(10)_
end

AfterConfiguration hook that will be run after Cucumber has been configured. This hook will run only once,after support has been loaded but before features are loaded. so it is usefull to launch Appium server.

Stoping the server:
at_exit do
_ exec ‘/usr/bin/killall -KILL node’_
end

at_exit will be executed after execution of all the feature files. So executing " exec '/usr/bin/killall -KILL node " command inside this hook kills the server at the end.


#202

Hi Hassan ,

I’m using the same which you mentioned above, but getting the below issue.

C:\Program’ is not recognized as an internal or external command,
operable program or batch file.


#203

You need to quote the path or escape the spaces:


#204

Hello people,
Can someone help. I’m getting connection refused message when I try to open appium server programatically. I’m attaching the error log.To be clear my appium server is taking really long to open. whenever it takes time I notice this connection refused error.

I’m using Appium v1.9.1 and using following methods to start and stop the appium server

public static void startAppium() {
Runtime runtime = Runtime.getRuntime();
try {
runtime.exec("cmd.exe /c start cmd.exe /k “appium -a 127.0.0.1 -p 4723"”);
Thread.sleep(10000);
}
catch(IOException e) {
e.printStackTrace();
}
catch(InterruptedException e1) {
e1.printStackTrace();
}
}

public static void stopAppium() {
    Runtime runtime = Runtime.getRuntime();
    try {
        runtime.exec("taskkill /F /IM node.exe");
        runtime.exec("taskkill /F /IM cmd.exe");
    }
    catch(IOException e) {
        e.printStackTrace();
    }
}

FAILED CONFIGURATION: @BeforeSuite initialize
org.openqa.selenium.WebDriverException: Connection refused: connect
Build info: version: ‘3.14.0’, revision: ‘aacccce0’, time: ‘2018-08-02T20:19:58.91Z’
System info: host: ‘C233309’, ip: ‘172.20.10.120’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_181’
Driver info: driver.version: AndroidDriver
at io.appium.java_client.remote.AppiumCommandExecutor.lambda$2(AppiumCommandExecutor.java:243)
at java.util.Optional.orElseGet(Unknown Source)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:242)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:212)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:130)
at io.appium.java_client.DefaultGenericMobileDriver.(DefaultGenericMobileDriver.java:38)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:84)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:94)
at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:93)
at com.cmsp.main.BaseTest.initialize(BaseTest.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:564)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:277)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1198)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1123)
at org.testng.TestNG.run(TestNG.java:1031)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at okhttp3.internal.platform.Platform.connectSocket(Platform.java:129)
at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:240)
at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:160)
at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:257)
at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:135)
at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:114)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200)
at okhttp3.RealCall.execute(RealCall.java:77)
at org.openqa.selenium.remote.internal.OkHttpClient.execute(OkHttpClient.java:105)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:101)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:185)
at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:209)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:231)
… 29 more