无法使用 UIScrollable 和 UISelector 定位元素

我正在使用此代码来选择元素


public static void swipe()

{


    MobileElement element = driver.findElementByAndroidUIAutomator(

                    "new UiScrollable(new UiSelector().class(\"android.widget.ImageView\")).getChildByText("

                    + "new UiSelector().resourceId(\"com.spotify.music:id/title\"), \"UnderCover\")");


    //Perform the action on the element

    System.out.println(element.getText()); //This would print - Unblock Me FREE

}

我把这个当作错误


io.appium.uiautomator2.common.exceptions.UiSelectorSyntaxException: Could not parse expression `new UiScrollable(new UiSelector().class("android.widget.ImageView")).getChildByText(new UiSelector().resourceId("com.spotify.music:id/title"), "UnderCover")`: UiScrollable has no suitable constructor with arguments [new UiSelector().class("android.widget.ImageView")]

at io.appium.uiautomator2.utils.UiExpressionParser.findConstructor(UiExpressionParser.java:232)


小怪兽爱吃肉
浏览 157回答 1
1回答

GCT1015

公共构造函数UIScrollable是:UiScrollable(UiSelector container);使用类似className的公共方法UiSelector:UiSelector className (String className); //or UiSelector className (Class<T> type);尝试new UiScrollable(new UiSelector().className("android.widget.ImageView"));代替new UiScrollable(new UiSelector().class("android.widget.ImageView"));
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java