@Hassan_Radi I refereed the article which you have provide and i am able to start the server and also cross verified in the task manager. But when i am setting up the capabilities i am getting the same error. Please find below code.
public class LaunchAppium {
static AppiumDriver driver;
@SuppressWarnings("rawtypes")
public static void main(String[] args) throws ExecuteException, IOException, InterruptedException {
ServerArguments serverArguments = new ServerArguments();
serverArguments.setArgument("--address", "127.0.0.1");
serverArguments.setArgument("--chromedriver-port", 9516);
serverArguments.setArgument("--bootstrap-port", 4725);
serverArguments.setArgument("--no-reset", true);
serverArguments.setArgument("--local-timezone", true);
serverArguments.setArgument("--platform-name", "ANDROID");
serverArguments.setArgument("--platform-version", "4.2.2");
serverArguments.setArgument("--device-name", "QO4301C12715");
serverArguments.setArgument("--app-pkg", "com.android.settings");
serverArguments.setArgument("--app-activity", "com.android.calendar.LaunchActivity");
AppiumServer _appiumServer = new AppiumServer(new File("D:/Appium"), serverArguments);
_appiumServer.startServer();
System.out.println(_appiumServer.isServerRunning());
DesiredCapabilities capabilities = new DesiredCapabilities();
/*capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability(CapabilityType.VERSION, "5.1.1");
capabilities.setCapability("platformName", "ANDROID");
capabilities.setCapability("deviceName", "QO4301C12715");
capabilities.setCapability("autoWebview", "true");
capabilities.setCapability("appPackage", "com.android.settings");
capabilities.setCapability("appActivity", "com.android.calendar.LaunchActivity");// com.android.calendar.LaunchActivity
capabilities.setCapability("newCommandTimeout", "180");
capabilities.setCapability("autoWebviewTimeout", "6000");*/
driver = new AndroidDriver(new URL("http://127.0.0.1:4725/wd/hub"),null);
AndroidDriver androidDriver = (AndroidDriver) driver;
androidDriver.startActivity("com.android.settings",
"com.android.settings.accounts.AddAccountSettings");
System.out.println("App Launched sucessfully:::");
}
}
Error Log:
Aug 19, 2015 3:13:52 PM com.github.genium_framework.appium.support.server.AppiumServer startServer
INFO: Server is starting...
Aug 19, 2015 3:13:53 PM com.github.genium_framework.appium.support.server.AppiumServer startServer
INFO: Server has not started yet. Trying again in one second...
Aug 19, 2015 3:13:55 PM com.github.genium_framework.appium.support.server.AppiumServer startServer
INFO: Server has not started yet. Trying again in one second...
Aug 19, 2015 3:13:57 PM com.github.genium_framework.appium.support.server.AppiumServer startServer
INFO: Server has not started yet. Trying again in one second...
Aug 19, 2015 3:13:58 PM com.github.genium_framework.appium.support.server.AppiumServer startServer
INFO: Server has been started successfully.
true
Aug 19, 2015 3:13:58 PM com.github.genium_framework.appium.support.server.AppiumServer isServerRunning
INFO: Checking to see if a server instance is running or not ...
Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.46.0', revision: '87c69e2', time: '2015-06-04 16:17:10'
System info: host: 'NAG1-LHP-41508', ip: '172.18.36.99', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_67'
Driver info: driver.version: AndroidDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:27)
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:242)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:128)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:155)
at io.appium.java_client.DefaultGenericMobileDriver.(DefaultGenericMobileDriver.java:22)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:202)
at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:50)
at account.LaunchAppium.main(LaunchAppium.java:65)
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to 127.0.0.1:4725 [/127.0.0.1] failed: Connection refused: connect
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:151)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:143)
at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:89)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:134)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:578)
... 10 more
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 org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:74)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:134)
... 23 more
Please help me to know how to initialize the appiumdriver or androiddriver with address and capabilities
driver = new AndroidDriver(new URL("http://127.0.0.1:4725/wd/hub"),capabilities);
i also tried with UN-commenting the capabilities code. But still the same error.