我是appium的新手,我正在尝试运行一个基本项目,我得到以下错误:
setUp(scenarios.AppiumTest): A new. session could not be created. (Original error: Bad app: D:\MyProject\apps\Flipkart.3.0.apk. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Error locating the app: ENOENT, stat 'D:\MyProject\apps\Flipkart.3.0.apk') (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 229 milliseconds
Build info: version: '2.46.0', revision: '61506a4624b13675f24581e453592342b7485d71', time: '2015-06-04 10:22:50'
System info: host: 'NODE211', ip: '192.168.47.1', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_51'
Driver info: io.appium.java_client.android.AndroidDriver
以下是我正在使用的代码。
package scenarios;
import io.appium.java_client.android.AndroidDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
public class AndroidSetup {
protected AndroidDriver driver;
protected void prepareAndroidForAppium() throws MalformedURLException {
File appDir = new File("D:/MyProject/apps");
File app = new File(appDir, "Flipkart.3.0.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("device","Android");
//mandatory capabilities`enter code here`
capabilities.setCapability("deviceName","Android");
capabilities.setCapability("platformName","Android");
//other caps
capabilities.setCapability("app", app.getAbsolutePath());
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}
}
请帮助我,谢谢
答案 0 :(得分:0)
您应该将文件的路径指定为:
"D:\\MyProject\\apps"
答案 1 :(得分:0)
请提供正确的.apk路径并使用以下代码
文件classPathRoot = new File(System.getProperty(“user.dir”));
文件appDir =新文件(classPathRoot,“/”);
文件app =新文件(appDir,“。apk”);
app.getAbsolutePath();
请尝试使用上面的代码。