How to automate OTP using selenium web driver?

Viewed 49798

I am doing automation for registration in a website but the problem is that it sends an OTP once i enter mobile no. after enter otp it will ask for password and than i am able to do registration.

Is there any way to get the OTP code once i enter mobile no ? or Can we automate OTP using selenium webdriver ?

2 Answers
String userProfile= "C:\\Users\\user\\AppData\\Local\\Google\\Chrome\\User Data\\";
        System.setProperty("webdriver.chrome.driver","C:\\Users\\user\\Desktop\\chromedriver.exe");
        ChromeOptions options = new ChromeOptions();
        options.addArguments("--user-data-dir="+userProfile);
        options.addArguments("--profile-directory=Default");
        options.addArguments("--start-maximized");
        WebDriver driver = new ChromeDriver(options);
        driver.get("https://mail.google.com/mail/u/0/#inbox");

The above code working fine for Automate the OTP verification sites..just create your local chrome trusted one time and call same browser using above code for testing..its quite cool :)

Related