你好,我在 mac 上,想跑下 appium 的 sample code
但是一直报 Error: Device android not configured yet
info: Error: Device android not configured yet,
我不知道哪里出的问题.能不能帮我看下
我安装的是 appium1.0
appium log:
debug: Appium request initiated at /wd/hub/session
debug: Request received with params: {"desiredCapabilities":{"platformVersion":"4.2","app":"/Users/build/appium/sample-code/examples/java/junit/../../../apps/ContactManager/ContactManager.apk","platformName":"Android","deviceName":"GT-P5113","browserName":"","app-package":"com.example.android.contactmanager","app-activity":".ContactManager"}}
error: Trying to run a session for device 'android' but that device hasn't been configured. Run config
info: Got configuration error, not starting session
info: Cleaning up appium session
error: Failed to start an Appium session, err was: Error: Device android not configured yet
info: Error: Device android not configured yet
at Appium.configure (/usr/local/lib/node_modules/appium/lib/appium.js:264:15)
at Appium.start (/usr/local/lib/node_modules/appium/lib/appium.js:102:10)
at exports.createSession (/usr/local/lib/node_modules/appium/lib/server/controller.js:155:16)
at callbacks (/usr/local/lib/node_modules/appium/node_modules/express/lib/router/index.js:164:37)
at param (/usr/local/lib/node_modules/appium/node_modules/express/lib/router/index.js:138:11)
at pass (/usr/local/lib/node_modules/appium/node_modules/express/lib/router/index.js:145:5)
at nextRoute (/usr/local/lib/node_modules/appium/node_modules/express/lib/router/index.js7)
at callbacks (/usr/local/lib/node_modules/appium/node_modules/express/lib/router/index.js:167:11)
at /usr/local/lib/node_modules/appium/lib/server/controller.js:41:7
at callbacks (/usr/local/lib/node_modules/appium/node_modules/express/lib/router/index.js:164:37)
info: Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Device android not configured yet)","origValue":"Device android not configured yet"},"sessionId":null}
POST /wd/hub/session 500 1ms - 216b
这是跑 mvn 的 log:
admins-MacBook-Pro:junit build$ mvn -Dtest=com.saucelabs.appium.AndroidContactsTest test
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.saucelabs:sauce_appium_junit:jar:0.0.1-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 60, column 12
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-surefire-plugin is missing. @ line 56, column 12
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building sauce_appium_junit 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ sauce_appium_junit ---
[debug] execute contextualize
[WARNING] Using platform encoding (EUC_CN actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/build/appium/sample-code/examples/java/junit/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ sauce_appium_junit ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ sauce_appium_junit ---
[debug] execute contextualize
[WARNING] Using platform encoding (EUC_CN actually) to copy filtered resources, i.e. build is platform dependent!
这是 test case code:
package com.saucelabs.appium;
import io.appium.java_client.AppiumDriver;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.io.File;
import java.net.URL;
import java.util.List;
public class AndroidContactsTest {
private AppiumDriver driver;
@Before
public void setUp() throws Exception {
// set up appium
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "../../../apps/ContactManager");
File app = new File(appDir, "ContactManager.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("deviceName","GT-P5113");
capabilities.setCapability("platformVersion", "4.2");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("app-package", "com.example.android.contactmanager");
capabilities.setCapability("app-activity", ".ContactManager");
driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}
@After
public void tearDown() throws Exception {
driver.quit();
}
@Test
public void addContact(){
WebElement el = driver.findElement(By.name("Add Contact"));
el.click();
//List textFieldsList = driver.findElementsByClassName("android.widget.EditText");
//textFieldsList.get(0).sendKeys("Some Name");
//textFieldsList.get(2).sendKeys("Some@example.com");
//driver.swipe(100, 500, 100, 100, 2);
//driver.findElementByName("Save").click();
}
}