How to read OTP in JAVA Selenium using android phone

0 votes
Hi,

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

Please help
Mar 13, 2020 in Selenium by sgokulvikas
• 120 points
5,203 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,610 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,500 points
8,402 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 6, 2020 in Selenium by Sri
• 3,190 points
18,964 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 6, 2018 in Selenium by nsv999
• 5,500 points
10,604 views
+10 votes
17 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
198,260 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 29, 2018 in Selenium by bug_seeker
• 15,510 points
1,952 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 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,060 views
+2 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP