-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSampleCode for OTP validation
44 lines (34 loc) · 1.55 KB
/
SampleCode for OTP validation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Using notification Pane
initiateDriver(extentReport); //To open the test App
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
driver.openNotifications();//Open notification Panel
//To Fetch the Messaging/OTP related notification
System.out.println(driver.findElementByXPath("//*[@resource-id='android:id/big_text' and contains(@text,'Your one time password')]").getText());
driver.navigate().back();// Close navigation pannel
// Using Messaging app
//Initialize the driver
initiateDriver(extentReport);//To Launch the Original App needs to be tested
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
//Opening Messaging App
driver.startActivity("com.google.android.apps.messaging",".ui.ConversationListActivity");
driver.findElement(By.xpath("(//*[@resource-id='com.google.android.apps.messaging:id/conversation_snippet' " +
"and" +
" contains(@text,'Dear Subscriber ENG vs NZ')])[1]")).click();
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
int msgSize= driver.findElements(By.xpath("//*[@resource-id='com.google.android.apps" +
".messaging:id/message_text']")).size();
System.out.println(driver.findElement(By.xpath("(//*[@resource-id='com.google.android.apps" +
".messaging:id/message_text'])["+msgSize+"]")).getText()); //Fetching the message with a particular type of Text
driver.startActivity("com.android.dialer","com.motorola.dialer.app.ExtendedDialtactsActivity"); // Switching back to Test ap