[英]how to get all values of editext in custom listview editext from mysql database in android
[英]How to get validation error message from EdiText in android native application by using UIAUTOMATOR
我正在尝试自动化android中的本机应用程序,在该应用程序中我具有登录功能。我自动化了正向流程。现在,我正尝试获取错误消息,如果我不填写电子邮件字段,该消息将显示在弹出窗口中。由UIAUTOMATORVIEWER无法识别。
我正在使用python和UIAUTOMATOR。有人建议我如何获取弹出窗口中显示的错误消息。
下面我附上图片。
我想打印弹出窗口中显示的“字段不能为空”消息。
print self.d(text='Email').text
给“电子邮件”文本而不是“字段不能为空”消息。
我只是编写此代码来给您一条路径。 根据您的要求进行提升:
Xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/tv_email"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="@color/Black"
android:text="Email"
android:textColor="@color/White" />
<TextView
android:id="@+id/tv_pass"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="@color/Black"
android:layout_below="@+id/tv_email"
android:text="Password"
android:textColor="@color/White" />
<FrameLayout
android:id="@+id/frame_for_email_error"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/tv_email"
android:visibility="gone">
<TextView
android:id="@+id/tv_pass"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="@color/Gray"
android:text="Field cannot be empty"
android:textColor="@color/Black" />
</FrameLayout>
</RelativeLayout>
当您的电子邮件为!(email.length> 0)时,请执行以下操作:
Java代码:
FrameLayout frame = (FrameLayout) findviewbyid(R.id.frame_for_email_error);
frame.setvisibility(View.Visible);
很抱歉告诉您,但您不能。 我也遇到过同样的问题(针对那个确切的情况和其他情况)。 UiAutomator只能看到uiAutomatorViewer识别的内容。
Ps:这也是UiAutomator无法读取/查找当前在屏幕上不可见的对象的原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.