我試圖運行一個測試,只是打開whatsapp messenger使用appium。我收到錯誤:無法創建新會話。 (原來的錯誤: 'Java的版本' 失敗錯誤:重生ENOENT)無法創建新會話。 (原始錯誤:'java -version'失敗。錯誤:spawn ENOENT)
這裏是我的代碼:
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Test;
public class WhatsApp{
public static void main(String[] args) throws MalformedURLException, InterruptedException
{
WebDriver dr;
String contact="1jyot";
File app = new File("C:\\Users\\ppantouveris\\workspace\\Downloading and Running Appium\\apk\\WhatsApp.apk");
DesiredCapabilities capabilities= new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("deviceName", "Vodafone Smart 4G");
capabilities.setCapability("platformVersion", "4.2.2");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appium-version", "1.3.4.1");
capabilities.setCapability("appPackage", "com.whatsapp");
//capabilities.setCapability("appActivity", "com.whatsapp.Main");
capabilities.setCapability("appActivity", ".Main");
dr = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities) ;
dr.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
}
}
任何想法?謝謝!
Appium以相同的功能啓動,但仍嘗試運行測試時出現同樣的錯誤。 JAVA_HOME和ANDROID_HOME設置正確,因爲java -version正常工作。 – Panos