我有以下Appium Testcase,它成功完成所有步骤并退出驱动程序。但是返回到控制台的结果是找不到会话,并且我不确定为什么所有步骤都已成功完成。
package amazon;
import io.appium.java_client.android.AndroidDriver;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.remote.DesiredCapabilities;
public class StartApplication {
private static AndroidDriver driver;
public static void main(String[] args) throws MalformedURLException, InterruptedException {
File classpathRoot = new File("C:\\workspace\\IJ Appium\\src\\resources\\Apps\\");
File app = new File(classpathRoot, "IrishJobs_com.saongroup.irishjobs.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "Craig Tab");
capabilities.setCapability("platformVersion", "4.4.2");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("app",app.getAbsolutePath() );
// capabilities.setCapability("appPackage", "IrishJobs_com.saongroup.irishjobs");
// capabilities.setCapability("appActivity", "com.amazon.mShop.home.HomeActivity");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
Thread.sleep(10000);
driver.findElement(By.className("android.widget.EditText")).click();
driver.findElement(By.className("android.widget.EditText")).sendKeys("Automation");
driver.hideKeyboard();
driver.findElement(By.className("android.widget.Button")).click();
Thread.sleep(150000);
driver.quit();
}
}
这是返回的错误
Exception in thread "main" org.openqa.selenium.remote.SessionNotFoundException:
Command duration or timeout: 24 milliseconds
Build info: version: '2.52.0', revision: '4c2593c', time: '2016-02-11 19:03:33'
System info: host: 'IE-DUB-MOB-106', ip: '10.32.74.140', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_71'
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities [{app=C:\workspace\IJ Appium\src\resources\Apps\IrishJobs_com.saongroup.irishjobs.apk, networkConnectionEnabled=true, warnings={}, databaseEnabled=false, deviceName=310096a22aefa200, platform=LINUX, desired={app=C:\workspace\IJ Appium\src\resources\Apps\IrishJobs_com.saongroup.irishjobs.apk, platformVersion=4.4.2, platformName=Android, deviceName=Craig Tab}, platformVersion=4.4.2, webStorageEnabled=false, locationContextEnabled=false, browserName=Android, takesScreenshot=true, javascriptEnabled=true, platformName=Android}]
Session ID: 2be92a35-54c9-4eb6-b642-176e65e13070
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:164)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:180)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:185)
at org.openqa.selenium.remote.RemoteWebDriver.quit(RemoteWebDriver.java:526)
at amazon.StartApplication.main(StartApplication.java:42)
答案 0 :(得分:0)
停止appium服务器,退出模拟器并重新启动。
答案 1 :(得分:0)
我认为您的Appium服务器因为长时间的睡眠而过早地关闭了连接。所以当它最终到达driver.quit()时,会话已经结束。
答案 2 :(得分:0)
如果您可以共享 appium服务器日志,那就太好了。
但肯定您的Thread.sleep()
时间超过--command-timeout
等于60 sec
- details about server flags
服务器用于所有会话的默认命令超时。 仍然会被newCommandTimeout上限
覆盖
虽然我不希望在测试中添加这么多延迟。但如果需要,您可以将其添加到服务器功能中:
capabilities.setCapability("newCommandTimeout", "200");