在Appium中收到错误消息“功能未实现”...请帮忙!
public class Login {
DesiredCapabilities上限; 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();
}
答案 0 :(得分: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()