Hi ,
I am new to Appium, I am trying to launch the chrome browser in emulator. I am getting the below error in eclipse trace.
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.
Can you please help me out from this problem.?
Here my code,
package com.Appium;
import io.appium.java_client.AppiumDriver;
import java.net.MalformedURLException;
import java.net.URL;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.BeforeTest;
public class AppiumBrowser {
private AppiumDriver driver;
public static String baseurl;
@BeforeTest
public void setup() throws MalformedURLException
{
System.out.println("Hello");
// File appDir = new File (“C:\Users\E595016\Downloads\”);
// File app = new File (appDir,“com.android.chrome-39.0.2171.59-2171059-minAPI14.apk”);
// DesiredCapabilities capabilities = new DesiredCapabilities ();
// capabilities.setCapability(“browsername”,“chrome”);
// capabilities.setCapability(“device”,“android”);
// capabilities.setCapability(“devicename”,“10.0.0.3:5554”);
// capabilities.setCapability(“platformversion”,“4.2.2”);
// capabilities.setCapability(“platformname”,“Android”);
//// capabilities.setCapability(“app”,app.getAbsolutePath());
// capabilities.setCapability(“appPackage”,“com.android.chrome”);
// capabilities.setCapability(“appActivity”,“com.google.android.apps.chrome.document.ChromeLauncherActivity”);
}
@Test
public void LaunchWebsite () throws Exception {
DesiredCapabilities cap = DesiredCapabilities.android();
//Capabilities = DesiredCapabilities.android();
//System.setProperty("webdriver.chrome.driver", "C:\\CloudATFTools\\selenium\\2.45\\drivers\\chromedriver_win32\\chromedriver.exe");
System.setProperty("webdriver.chrome.driver", "C:\\Appium\\AppiumForWindows-1.3.4.1\\Appium\\node_modules\\appium\\build\\chromedriver\\windows\\chromedriver.exe");
cap.setPlatform(Platform.WINDOWS);
cap.setCapability("deviceName", "Android Emulator");
cap.setCapability("platformName", "Android");
cap.setCapability("browserName", "Chrome");
AppiumDriver driver=new AppiumDriver(new URL("http://127.0.0.1:4725/wd/hub"), cap);
Thread.sleep(10000);
baseurl = "www.google.com";
driver.get(baseurl+"/");
//driver.findElement(By.className("android.widget.EditText")).click();
// Wait for the search text box to be visible, then
// enter the search term "Kangaroo"
driver.findElement(By.id("lst-ib")).sendKeys("Kangaroo");
driver.findElement(By.className("lsb")).click();
// Find the first entry for Kangaroo from WikiPedia
// Look for the element that has "ikipedia" in the link text and click it
driver.findElement(By.partialLinkText("ikipedia")).click();
// The click should load the Wikipedia entry. Wait for it to load
driver.findElement(By.className("mw-wiki-logo"));
// Verify that the page title contains Wikipedia
// verify.assertTrue(driver.getTitle().contains("Wikipedia"), "Check title of Wikipedia page");
}
}
Thanks,
Vital