Skip to content

Commit b0c3419

Browse files
Merge pull request #520 from sravanmedarapu/master
Added test to verify TOAST messages
2 parents abf1bfe + 35f6290 commit b0c3419

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

src/test/java/io/appium/java_client/android/UIAutomator2Test.java

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package io.appium.java_client.android;
22

3-
import static org.junit.Assert.assertEquals;
43

4+
import io.appium.java_client.MobileBy;
5+
import io.appium.java_client.MobileElement;
56
import io.appium.java_client.remote.AutomationName;
67
import io.appium.java_client.remote.MobileCapabilityType;
78
import io.appium.java_client.service.local.AppiumDriverLocalService;
@@ -10,10 +11,17 @@
1011
import org.junit.AfterClass;
1112
import org.junit.BeforeClass;
1213
import org.junit.Test;
14+
import org.openqa.selenium.By;
1315
import org.openqa.selenium.DeviceRotation;
1416
import org.openqa.selenium.remote.DesiredCapabilities;
17+
import org.openqa.selenium.support.ui.ExpectedConditions;
18+
import org.openqa.selenium.support.ui.WebDriverWait;
1519

1620
import java.io.File;
21+
import java.util.concurrent.TimeUnit;
22+
23+
import static org.junit.Assert.assertEquals;
24+
import static org.junit.Assert.assertNotNull;
1725

1826
public class UIAutomator2Test {
1927
private static AppiumDriverLocalService service;
@@ -38,6 +46,7 @@ public class UIAutomator2Test {
3846
capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
3947
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.ANDROID_UIAUTOMATOR2);
4048
driver = new AndroidDriver<>(service.getUrl(), capabilities);
49+
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
4150
}
4251

4352
/**
@@ -74,4 +83,29 @@ public class UIAutomator2Test {
7483
driver.rotate(landscapeRightRotation);
7584
assertEquals(driver.rotation(), landscapeRightRotation);
7685
}
86+
87+
@Test public void testToastMSGIsDisplayed() throws InterruptedException {
88+
final WebDriverWait wait = new WebDriverWait(driver, 10);
89+
driver.startActivity("io.appium.android.apis", ".view.PopupMenu1");
90+
91+
MobileElement popUpElement = driver.findElement(MobileBy.AccessibilityId("Make a Popup!"));
92+
popUpElement.click();
93+
driver.findElement(By.xpath(".//*[@text='Search']")).click();
94+
assertNotNull(wait.until(ExpectedConditions.presenceOfElementLocated(
95+
By.xpath("//*[@text='Clicked popup menu item Search']"))));
96+
97+
popUpElement.click();
98+
driver.findElement(By.xpath(".//*[@text='Add']")).click();
99+
assertNotNull(wait.until(ExpectedConditions
100+
.presenceOfElementLocated(By.xpath("//*[@text='Clicked popup menu item Add']"))));
101+
102+
popUpElement.click();
103+
driver.findElement(By.xpath(".//*[@text='Edit']")).click();
104+
assertNotNull(wait.until(ExpectedConditions
105+
.presenceOfElementLocated(By.xpath("//*[@text='Clicked popup menu item Edit']"))));
106+
107+
driver.findElement(By.xpath(".//*[@text='Share']")).click();
108+
assertNotNull(wait.until(ExpectedConditions
109+
.presenceOfElementLocated(By.xpath("//*[@text='Clicked popup menu item Share']"))));
110+
}
77111
}

0 commit comments

Comments
 (0)