[英]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.