我正在真实设备上启动应用程序 正在登录 在主屏幕上着陆 ANDROID设备中的app不能识别主屏幕元素。我试图点击右上角的帮助图标。
请注意,在任何主屏幕元素上执行操作都是断断续续的
我尝试过的事情: -我登录后要等待。 -登录后返回首页对象 -在我使用'initElements'初始化主页对象之前,需要等待更多时间。 -在首页构造函数中,我尝试了findElementsById,findElementById,并尝试在调用initElements之前将元素动态等待 -已尝试所有元素的ID -已尝试对所有元素使用xpath -尝试杀死应用并重新启动应用,然后再次尝试识别元素 -尝试过JavascriptExecutor -尝试点击方法
// 下面是主页对象屏幕的构造函数,该结构在我登录后被调用。
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“,”上下文“:”“,”多个“:true}} [AndroidBootstrap] [引导日志] [调试]从客户端获取数据:{“ cmd”:“ action”,“ action”:“ find”,“ params”:{“ strategy”:“ id”,“ selector”:“ com.payu.payunow:id / frag_home_help_imgview_id“,”上下文“:”“,”多个“:true}} [AndroidBootstrap] [BOOTSTRAP LOG] [debug]得到了ACTION类型的命令 [AndroidBootstrap] [BOOTSTRAP LOG] [debug]有命令操作:查找 [AndroidBootstrap] [引导日志] [调试]使用带有上下文ID的“ ID”查找“ com.payu.payunow:id / frag_home_help_imgview_id”:” Multiple:true [AndroidBootstrap] [BOOTSTRAP LOG] [debug]使用:UiSelector [RESOURCE_ID = com.payu.payunow:id / frag_home_help_imgview_id] [AndroidBootstrap] [引导日志] [调试] getElements选择器:UiSelector [RESOURCE_ID = com.payu.payunow:id / frag_home_help_imgview_id] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Element []为空:(0) [AndroidBootstrap] [引导日志] [调试] getElements tmp选择器:UiSelector [INSTANCE = 0,RESOURCE_ID = com.payu.payunow:id / frag_home_help_imgview_id] [AndroidBootstrap] [引导日志] [调试]无法找到元素。清除辅助功能缓存并重试。 [AndroidBootstrap] [引导日志] [调试]使用带有上下文ID的“ ID”查找“ com.payu.payunow:id / frag_home_help_imgview_id”:多个:true
答案 0 :(得分:0)
尝试等待直到启用该元素。您可以使用 WebDriverWait 类。 wait.until(ExpectedConditions.elementToBeClickable(<element_locator>), <your_timeout>));