2017-07-17 68 views
1

在Appium中收到錯誤消息「功能未實現」...請幫助!Appium中未實現的功能錯誤消息

公開課登錄{

DesiredCapabilities caps; AndroidDriver驅動程序;

@BeforeTest 
public void test() throws MalformedURLException, WebDriverException, InterruptedException { 

    File appdir= new File("src"); 
    File app= new File(appdir, "ECare.apk"); 

    caps= new DesiredCapabilities(); 
    caps.setCapability(MobileCapabilityType.PLATFORM_NAME,Platform.ANDROID); 
    caps.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator"); 
    caps.setCapability(MobileCapabilityType.APPIUM_VERSION, "1.4.16.1"); 
    caps.setCapability(MobileCapabilityType.APP, app.getAbsolutePath()); 
    //caps.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 300000); 
    caps.setCapability(MobileCapabilityType.HAS_TOUCHSCREEN, "True"); 
    driver=new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), caps); 
    driver.manage().timeouts().implicitlyWait(9, TimeUnit.SECONDS); 
} 


@Test 
public void okOnAlert() throws InterruptedException 
{ 
    WebDriverWait wait= new WebDriverWait(driver, 2); 
    wait.until(ExpectedConditions.alertIsPresent()); 
    Alert alert= driver.switchTo().alert(); 
    driver.findElementById("com.android.packageinstaller:id/dialog_container").getText(); 
    Thread.sleep(3000); 
    alert.accept(); 
} 

@AfterTest 
public void End() 
{ 
    driver.quit(); 
} 

} Trying to click on allow button but unable to click :(

+1

這將是有益的,看看整個錯誤輸出,並有其背景出現問題的詳細信息。 – rene

回答

0
driver.switchTo().alert(); is not for mobile applications. You have to find Xpath of button which you want to click and perform click operation on that. For Example : 

@findBy(id="android:/button1") 
public WebElement ok; 

// once you identified your element , click on the desired button. 

ok.Click() 
+0

請花一分鐘將代碼中的代碼格式化爲代碼。 – JeffC

+0

非常感謝你......我知道我要去哪裏了..謝謝你的幫助! :) – ruchi