繁体   English   中英

尝试检查应用程序的方向时出错?

[英]I am getting error while trying to check orientation of app?

我尝试了以下代码,但它显示错误消息:

driver.rotate(org.openqa.selenium.ScreenOrientation.LANDSCAPE); 
Thread.sleep(5000); driver.rotate(org.openqa.selenium.ScreenOrientation.PORTRAIT); 
Thread.sleep(5000);

错误信息:-

处理命令时发生未知的服务器端错误。 (警告:服务器没有提供任何堆栈跟踪信息)

"Set the orientation, but app refused to rotate."似乎有解决方案"Set the orientation, but app refused to rotate." 错误信息。 您的问题可能与应用程序依赖传感器进行旋转并且不允许用户进行设置有关。 至少“maxski”就是这种情况: https ://discuss.appium.io/t/android-set-the-orientation-but-app-refused-to-rotate/3200/3

"The problem was in Android app code. Devs should set orientation reliance to user not to censor."

使用下面的代码来识别方向是否为纵向。
public boolean Method_isCurrentOrientationPortrait(@SuppressWarnings("rawtypes") AppiumDriver driver) { String ort = driver.getOrientation().name(); ScreenOrientation 方向 = ScreenOrientation.valueOf(ort);

    if (orientation == ScreenOrientation.PORTRAIT) {
        System.out.println("Current screen orientation is portrait");
        return true;

    } else {
        System.out.println("Current screen orientation is Landscape");

        return false;
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM