11package 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 ;
56import io .appium .java_client .remote .AutomationName ;
67import io .appium .java_client .remote .MobileCapabilityType ;
78import io .appium .java_client .service .local .AppiumDriverLocalService ;
1011import org .junit .AfterClass ;
1112import org .junit .BeforeClass ;
1213import org .junit .Test ;
14+ import org .openqa .selenium .By ;
1315import org .openqa .selenium .DeviceRotation ;
1416import org .openqa .selenium .remote .DesiredCapabilities ;
17+ import org .openqa .selenium .support .ui .ExpectedConditions ;
18+ import org .openqa .selenium .support .ui .WebDriverWait ;
1519
1620import 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
1826public 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