How to read OTP in JAVA Selenium using android phone

+1 vote
Hi,

I need Java Selenium code to read the OTP from android phone.

Please help
Mar 13, 2020 in Selenium by sgokulvikas
• 130 points
1,209 views
Can you share the code to read otp from android phone using java selenium
Have you tried using @Karan's Solution?

2 answers to this question.

0 votes
i can help you to read
answered Mar 19, 2020 by anonymous
I have been trying to look for a solution, could you please tell me how I could do this?
0 votes

Try the following:

Step 1: Connect the Phone/Dongle to the COM Port via USB.

Step 2: Call the code for fetching sms via smslib.jar

Sample Code to fetch sms:

public void sendSMS() throws Exception{
    OutboundNotification outboundNotification = new OutboundNotification();
    SerialModemGateway gateway = new SerialModemGateway("modem.com5", "COM5", 9600, "ZTE", "COM5");
    gateway.setInbound(true);
    gateway.setOutbound(true);
    gateway.setSmscNumber("+91XXXXXXXXXX"); // 10-digit Mobile Number
    Service.getInstance().setOutboundMessageNotification(outboundNotification);
    Service.getInstance().addGateway(gateway);
    Service.getInstance().startService();
    OutboundMessage msg = new OutboundMessage(ExcelConnect.strSMSTo, ExcelConnect.strSMSText);
    Service.getInstance().sendMessage(msg);
    System.out.println(msg);
    System.out.println(ExcelConnect.strSMSTo + "-" + ExcelConnect.strSMSText);
    Service.getInstance().stopService();
    Service.getInstance().removeGateway(gateway);
}

Step 3: Parse sms to get the OTP from the fetched list by latest received sms.

answered Oct 7, 2020 by Karan
• 19,580 points

Related Questions In Selenium

+1 vote
1 answer

How to handle drop downs using Selenium WebDriver in Java

First, find an XPath which will return ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,520 points
5,033 views
0 votes
2 answers

How to scroll the Page up or down in Selenium WebDriver? (using java)

JavascriptExecutor jsx = (JavascriptExecutor)driver; jsx.executeScript("window.scrollBy(0,555)", ""); or Action classes ...READ MORE

answered Sep 5, 2020 in Selenium by Sri
• 3,010 points
14,449 views
0 votes
1 answer

How to handle Pop-up in Selenium WebDriver using Java

Actually, its pretty simple. Use this code ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,520 points
8,022 views
+11 votes
16 answers

How to automate gmail login process using selenium webdriver in java?

Check the below code: Here is the working ...READ MORE

answered Apr 24, 2018 in Selenium by Vardy
• 2,360 points
132,585 views
0 votes
1 answer

How to wait for the webpage to load in selenium using java

Firstly, when you launch a web application, ...READ MORE

answered Aug 28, 2018 in Selenium by bug_seeker
• 15,550 points
776 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
947 views
+2 votes
1 answer