Reputation: 11
Hey guys so I've basically done what needs to be done to get appium up and going. Installed JDK 1.8 (latest version) Installed Android SDK Updated environment variables installed appium 1.4 (Latest ver) Installed Eclipse and create a new java project after connecting my phone to my pc.
I imported the .apk file to the project and when I set the desired capabilites. I do not have any errors in my code. After launching appium, I run my code and I get the following error:
Starting Node Server warn: Appium support for versions of node < 0.12 has been deprecated and will be removed in a future version. Please upgrade! info: Welcome to Appium v1.4.0 (REV 8f63e2f91ef7907aed8bda763f4e5ca08e86970a) info: Appium REST http interface listener started on 127.0.0.1:4723 info: [debug] Non-default server args: {"address":"127.0.0.1","logNoColors":true,"platformName":"Android","platformVersion":"18","automationName":"Appium"} info: Console LogLevel: debug info: --> POST /wd/hub/session {"desiredCapabilities":{"app":"C:\Users\svaradar\workspace\LiftMasterAndroidApp\LM_APK\LiftMaster.apk","appPackage":"com.chamberlain.myq.chamberlain","appActivity":"com.chamberlain.myq.activity.LoginActivity","browserName":"","platformName":"Android","version":"5.0","deviceName":"e6feb2e2"}} info: Client User-Agent string: Apache-HttpClient/4.4.1 (Java/1.8.0_51) info: [debug] The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : version info: [debug] Using local app from desired caps: C:\Users\svaradar\workspace\LiftMasterAndroidApp\LM_APK\LiftMaster.apk info: [debug] Creating new appium session 27b1f84e-556e-4881-8afc-d9ea50941f12 error: Failed to start an Appium session, err was: Error: 'java -version' failed. Error: spawn ENOENT info: Starting android appium info: [debug] Getting Java version info: [debug] Cleaning up android objects info: [debug] Cleaning up appium session info: [debug] Error: 'java -version' failed. Error: spawn ENOENT at [object Object]. (C:\Users\svaradar\Desktop\Automation\Appium\node_modules\appium\lib\devices\android\android-common.js:1057:17) at exithandler (child_process.js:633:7) at ChildProcess.errorhandler (child_process.js:649:5) at ChildProcess.EventEmitter.emit (events.js:95:17) at Process.ChildProcess._handle.onexit (child_process.js:795:12) info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: 'java -version' failed. Error: spawn ENOENT)","origValue":"'java -version' failed. Error: spawn ENOENT"},"sessionId":null} info: <-- POST /wd/hub/session 500 17.573 ms - 208
Here is my code:
package LiftMasterLaunch;
import java.net.MalformedURLException;
import java.net.URL;
import java.io.File;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.junit.*;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
public class openApp {
@SuppressWarnings("rawtypes")
private AppiumDriver driver;
@SuppressWarnings("rawtypes")
@Before
public void setUp() throws Exception{
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "/LM_APK" );
File app = new File(appDir, "LiftMaster.apk" );
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("platformName","Android");
capabilities.setCapability(CapabilityType.VERSION, "5.0");
capabilities.setCapability("deviceName", "e6feb2e2");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", "com.chamberlain.myq.chamberlain");
capabilities.setCapability("appActivity", "com.chamberlain.myq.activity.LoginActivity");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}
@Test
public void testApp() throws Exception {
driver.findElement(By.xpath(("//android.widget.EditText[@text='Account Email']"))).sendKeys("[email protected]");
}
@After
public void tearDown() throws Exception {
driver.quit();
}
}
Upvotes: 1
Views: 1352
Reputation: 157
In my case the solution was setting java in PATH before the Appium and Android paths.
Upvotes: 1
Reputation: 11
I fixed this issue and am updating this in case someone else runs into this.
All I had to do was add "%SystemRoot%\system32" for Path underneath my system variables. That fixed the problem.
Upvotes: 0