Java 如何在selendroid中验证toast消息
我需要验证toast消息,如“创建成功”。我尝试使用linktext。但它不工作。有人能帮我吗?请在您的selendroid代码中使用以下代码Java 如何在selendroid中验证toast消息,java,android,selenium,automation,selendroid,Java,Android,Selenium,Automation,Selendroid,我需要验证toast消息,如“创建成功”。我尝试使用linktext。但它不工作。有人能帮我吗?请在您的selendroid代码中使用以下代码 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/toast_layout_root" android:orientation="horizontal" android:layout_width=
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toast_layout_root"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
android:background="#DAAA" >
<ImageView android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginRight="10dp" />
<TextView android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:textColor="#FFF" />
</LinearLayout>
waitForElement(By.partialLinkText(“您的祝酒词”),4,驱动程序)强>
其中第一个参数是您的toast消息。第二个参数是以秒为单位的持续时间,第三个参数是驱动程序。使用Selendroid自动化工具,我需要验证toast消息是否有任何方法可以捕获toast并打印它?我将尝试捕获,并将很快更新。请对答案投赞成票,以便对其他人也有帮助
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.toast_layout,
(ViewGroup) findViewById(R.id.toast_layout_root));
ImageView image = (ImageView) layout.findViewById(R.id.image);
image.setImageResource(R.drawable.android);
TextView text = (TextView) layout.findViewById(R.id.text);
text.setText("Hello! This is a custom toast!");
Toast toast = new Toast(getApplicationContext());
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(layout);
toast.show()