appium을 처음 사용합니다.appium에서 요소를 찾는 방법
쇼핑 앱 (Flipkart)의 자동화 기능으로 appium을 배우고 있습니다.
내가 요소 5 요소 에서 "권장 당신을위한 할인" 목록을 선택하려합니다.
이렇게하려면 해당 요소에 손을 뻗기 위해 가로 스크롤을해야합니다. 하지만 문제가 발생했습니다 "당신을위한 권장 할인"의 요소가있는 컨테이너 요소를 얻으므로 5th element
을 가져올 수 있습니다.
나는 문제가 플립 카드의 UI가 항상 바뀌고 있다고 생각합니다.
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
Thread.sleep(3000);
driver.scrollToExact("Recommended Offers for You");
Thread.sleep(10000);
// Getting error on below line
AndroidElement ele = (AndroidElement) driver.findElement(By.xpath("//android.support.v7.widget.RecyclerView[@index='1']"));
for(int i=0;i<4;i++)
{
Thread.sleep(2000);
if (ele.findElement(By.xpath("android.widget.RelativeLayout[@index='2']")).isDisplayed())
{
ele.findElement(By.xpath("android.widget.RelativeLayout[@index='2']")).click();
break;
}
else
{
horizontalScroll(ele);
}
}
public void horizontalScroll(AndroidElement ele)
{
Dimension size=driver.manage().window().getSize();
int x_start=(int)(size.width*0.60);
int x_end=(int)(size.width*0.30);
int y=130;
ele.swipe(SwipeElementDirection.RIGHT,x_end,y,4000);
}
나는 find elements
에 uiautomator
을 사용하고 있습니다. 다음은 UI의 스크린 샷입니다. 응용 프로그램의 UI가 표시 될 때 경우 요소를 찾을 수있는 가장 좋은 방법은
을 얻는 경우
동일한 resource_id를 가진 자원이 여러 개인 경우 어떻게 될까요? 동일한 resource_id를 갖는 여러 리소스를보고 있기 때문에 – Ankur
RecyclerView에서 항목은 동일한 View이기 때문에 매우 일반적으로 동일한 resourceIds를 갖습니다. 고유 항목을 사용하여 RecyclerView를 채우지 않는 한 RecyclerView의 의도에 어긋나지 않는 한. – Daniel