gpt4 book ai didi

android - 使用 UIAutomator 单击 MarkerOptions

转载 作者:行者123 更新时间:2023-11-29 01:18:21 28 4
gpt4 key购买 nike

我试图让 UIAutomator 点击 Google map 上的 MarkerOptions。 This solution does not work ..

build.gradle(应用级别)

dependencies {
androidTestCompile 'com.android.support.test:runner:0.3'
androidTestCompile 'com.android.support.test:rules:0.3'
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1'
}

测试类

@RunWith(AndroidJUnit4.class)
public class ApplicationTest {

UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
UiObject marker = device.findObject(new UiSelector().descriptionContains("title_of_marker. snippet_of_marker."));
try {
marker.click();
} catch (UiObjectNotFoundException e) {
e.printStackTrace();
}
}

MapsFragment.java

private GoogleMap mMapView;

private void loadMapLocations() {

mMapView.addMarker(new MarkerOptions()
.position(new LatLng(52.0988198,5.074657))
.title("title_of_marker")
.snippet("snippet_of_marker"));
}

enter image description here

输出:

W/System.err: android.support.test.uiautomator.UiObjectNotFoundException: UiSelector[CONTAINS_DESCRIPTION=title_of_marker. snippet_of_marker.]
W/System.err: at android.support.test.uiautomator.UiObject.click(UiObject.java:412)

我已经尝试了所有方法,但现在不知道如何进行。

最佳答案

我已经使用了@Diego 的示例代码并将其粘贴到我的ApplicationTest.java 中并且这有效,所以我不需要使用 Culebra:

@Test
public void loginAndClickMarker() {

UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
final BySelector bySelector = By.clazz(Pattern.compile(".*")).desc("title_of_marker. snippet_of_marker.").pkg("www.brandmkrs.com.damageapp");
device.wait(Until.hasObject(bySelector), DEFAULT_TIMEOUT);
device.findObject(bySelector).clickAndWait(Until.newWindow(), DEFAULT_TIMEOUT);
SystemClock.sleep(1000);
}

关于android - 使用 UIAutomator 单击 MarkerOptions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38340088/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com