I need to verify a toast message like "created successfully". I tried by using linktext. But its not working.Can anyone help me regarding this?
Asked
Active
Viewed 1,863 times
2 Answers
7
Please use following code in your selendroid code
waitForElement(By.partialLinkText("Your Toast message"), 4, driver);
where first parameter is your toast message. Second parameter is Time duration in Seconds,third is driver.

Sachin Tyagi
- 1,257
- 15
- 21
-
Is there any way to capture the toast and print it? – user2632692 Oct 16 '14 at 04:18
-
I will try to capture and will update soon ..Please Vote for the answer so that it will be helpful to other also – Sachin Tyagi Oct 16 '14 at 13:14
0
<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>
MainActivity.java
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()

Digvesh Patel
- 6,503
- 1
- 20
- 34
-
Using Selendroid automation tool, I need to verify the toast message – user2632692 Jul 17 '14 at 08:46