【发布时间】:2019-09-21 02:56:47
【问题描述】:
场景:
我正在真实设备上启动应用程序 登录 登陆主屏幕 ANDROID 设备中的 appium 无法识别主屏幕元素。我尝试点击右上角的帮助图标。
注意在任何主屏幕元素上执行操作都是间歇性的
我尝试过的: - 登录后等待。 - 登录后返回主页对象 - 在我使用“initElements”初始化主页对象之前,请稍等。 - 在主页构造函数中我尝试了 findElementsById、findElementById,我尝试在调用 initElements 之前放置元素的动态等待 - 尝试了所有元素的 id - 已为所有元素尝试过 xpath - 试图杀死应用程序并重新启动应用程序并再次尝试识别元素 - 尝试过 JavascriptExecutor - 尝试过tap方法
//下面是我登录后调用的主页对象屏幕的构造函数。
public HomePageObjectsNew(Config testConfig) {
this.testConfig = testConfig;
PlatformName = testConfig.getRunTimeProperty("platformNameMobile");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
List<MobileElement> abc= MobileActions.findElementsById(testConfig, "frag_home_help_imgview_id");
testConfig.logComment(Integer.toString(abc.size()));
PageFactory.initElements(new AppiumFieldDecorator(testConfig.driver, 5, TimeUnit.SECONDS), this);
}
//*Login Method:*
public HomePageObjectsNew loginFlowUsingPassword() {
swipeWalkthroughScreens();
enterAlreadyExistingEmailID("coios6@yopmail.com");
Browser.wait(testConfig, 2);
MobileActions.waitForVisibility(testConfig, txtFldPassword,
"Password field");
enterPassword();
clickOnLogin();
Browser.wait(testConfig, 4);
return new HomePageObjectsNew(testConfig);
}
//*My test case:*
@Test(description = "Verify successful Login of an existing now merchant using password flow", dataProvider = "GetMobileTestConfig", timeOut = 700000)
public void verifyPaymentRequestButtonIsClickableAfterLogin(Config testConfig) {
try {
LoginSignUpPageObjects loginSignUpPageObjects = new LoginSignUpPageObjects(testConfig);
HomePageObjectsNew obj = loginSignUpPageObjects.loginFlowUsingPassword();
obj.btnHelpScreenHeader.click();
MobileActions.goBack(testConfig);
obj.clickOnHamburgerMenu();
Browser.wait(testConfig, 2);
obj.clickOnHamburgerMenu();
loginSignUpPageObjects.clickOnRequestPayment();
System.out.println("Request Button clicked");
} catch (Exception e) {
testConfig.logFail("verifyPaymentRequestButtonIsClickableAfterLogin failed !!");
e.printStackTrace(System.out);
}
}
**Actual:** Not able to click on Home screen elements
So if i try 10 times only 1 time it works ... NOTE that id's are not dynamic have already confirmed with DEV !!
**Expected:** I should be able to click on home page elements
Appium 日志: [MJSONWP (6fbddb32)] 使用 args 调用 AppiumDriver.findElements():["id","com.payu.payunow:id/frag_home_help_imgview_id","6fbddb32-3ee5-4237-beee-c0496d88e69e"] [BaseDriver] 此请求的有效定位器策略:xpath、id、类名、可访问性 id、-android uiautomator [BaseDriver] 等待长达 5000 毫秒的条件 [AndroidBootstrap] 向 android 发送命令:{"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.payu.payunow:id /frag_home_help_imgview_id","context":"","multiple":true}} [AndroidBootstrap] [BOOTSTRAP LOG] [debug] 从客户端获取数据:{"cmd":"action","action":"find","params":{"strategy":"id","selector":" com.payu.payunow:id/frag_home_help_imgview_id","context":"","multiple":true}} [AndroidBootstrap] [BOOTSTRAP LOG] [debug] 得到 ACTION 类型的命令 [AndroidBootstrap] [BOOTSTRAP LOG] [debug] 得到命令动作:find [AndroidBootstrap] [BOOTSTRAP LOG] [debug] 使用 'ID' 和 contextId: '' multiple: true [AndroidBootstrap] [BOOTSTRAP LOG] [debug] 使用:UiSelector[RESOURCE_ID=com.payu.payunow:id/frag_home_help_imgview_id] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements 选择器:UiSelector[RESOURCE_ID=com.payu.payunow:id/frag_home_help_imgview_id] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Element[] 为空:(0) [AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements tmp 选择器:UiSelector[INSTANCE=0, RESOURCE_ID=com.payu.payunow:id/frag_home_help_imgview_id] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] 未能定位元素。清除辅助功能缓存并重试。 [AndroidBootstrap] [BOOTSTRAP LOG] [debug] 使用带有 contextId: '' multiple: true 的 'ID' 查找 'com.payu.payunow:id/frag_home_help_imgview_id'
【问题讨论】:
-
你也可以发布appium日志吗?
-
您好 Manish,欢迎来到堆栈溢出。一个小建议:最好将新信息放在您的问题中,而不是 cmets。它将使新信息更具可见性,从而帮助您获得更好的答案。
标签: java selenium-webdriver appium