0
當我在TestNG的權限啓動活動否認重啓沒有幫助
`package TrainingDay3;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.By;
import io.appium.java_client.android.AndroidDriver;
import org.openqa.selenium.WebDriver;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.AfterClass;
public class Test1 {
private static WebDriver driver;
@BeforeClass
public void beforeClass() {
//public static void main(String[] args) throws MalformedURLException {
File file = new File("D:\\workspace\\AppiumTraining\\apk\\app-qa-debug_original.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("Version", "6.0.1");
capabilities.setCapability("deviceName", "XT-1254");
capabilities.setCapability("app", file.getAbsolutePath());
capabilities.setCapability("appPackage", "org.aarp.careconnect");
capabilities.setCapability("appActivity", "org.aarp.careconnect.activities.MainActivity");
try {
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Test
public void f() {
//locate the Text on the app by using By.className()
//driver.findElement(By.className("android.widget.Button")).click();//("android.widget.Button")).click();
//driver.findElement(By.className("android.view.View")).click();
//driver.findElement(By.className("android.widget.EditText")).click();
//driver.findElement(By.className("android.widget.Button")).click();
}
@AfterClass
public void afterClass() {
// TODO: handle exception
//close the app
driver.quit();
}
}`
運行此腳本越來越例外配置失敗appium服務器:@BeforeClass beforeClass org.openqa.selenium.SessionNotCreatedException:一個新的會話不能被創建。 (原來的錯誤:權限開始被拒絕的活動。)(警告:服務器沒有提供任何堆棧跟蹤信息) 命令持續時間或超時:0毫秒 生成信息:版本:「未知」,修訂版:「1969d75」,時間:' 2016-10-18 09:43:45 -0700'雖然我已經多次重新啓動了appium服務器,但它無濟於事。