我嘗試使用下面的代碼滾動到一個元素:Appium-uiAutomator工作正常,爲Android而不是iOS的
@AndroidFindBy(uiAutomator = 「新UiScrollable(新UiSelector())scrollIntoView(」 + 「new UiSelector()。text(\」Contacts \「));」) @iOSFindBy(uiAutomator =「new UiScrollable(new UiSelector())。scrollIntoView(」+「new UiSelector()。text(\ 「));」) public MobileElement orgContact;
這完全適用於Android的,但在iOS上,我得到以下錯誤: org.openqa.selenium.NoSuchElementException:無法通過這一戰略定位的元素:定位地圖: - 本機內容:「By.IosUIAutomation:新的UiScrollable(new UiSelector())。scrollIntoView(new UiSelector().text(「Contacts」));「
我也曾嘗試使用滾動: 公共無效verticalScroll(AppiumDriver司機){
this.driver=driver;
dimensions = driver.manage().window().getSize();
Double screenHeightStart = dimensions.getHeight() * 0.5;
int scrollStart = screenHeightStart.intValue();
System.out.println("s="+scrollStart);
Double screenHeightEnd = dimensions.getHeight() * 0.2;
int scrollEnd = screenHeightEnd.intValue();
driver.swipe(0,scrollStart,0,scrollEnd,5000);
} 但它也不起作用。 任何人都可以請建議我在這裏做錯了什麼