我的 Windows 应用程序至少需要 15 秒才能加载。但是 appium 服务器不使用 Thread.sleep 或以下方法等待。请帮忙。如何使用 Java 让 appium 服务器等待?
@Test(priority = 1)
public void simple_test() throws Exception {
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability("app", "C:\\SITA\\********************");
cap.setCapability("platformName", "Windows");
cap.setCapability("deviceName", "WindowsPC");
driver = new WindowsDriver( new URL ("http://127.0.0.1:4723"), cap);
Thread.sleep(30);
}
@Test(priority = 2)
public void login() throws InterruptedException {
int startTime = 0;
int waittime =30;
while (startTime < waittime)
{
try
{
WebElement user = driver.findElementByAccessibilityId("TextBox");
if (!user.isDisplayed())
startTime += 1;
else
{
Thread.sleep(1000);
return;
}
}
catch (Exception ex)
{
Thread.sleep(1000);
return; // We should have Control loaded by now
}
Thread.sleep(1000);
}
WebElement user = driver.findElementByAccessibilityId("TextBox");
user.sendKeys("testadmin");
WebElement passwrd = driver.findElementByAccessibilityId("txtPassword");
passwrd.sendKeys("admin@123");
System.out.println("*****");
}
测试不等待上述方法。