How to handle OTP screen which is generated from API in Selenium Webdriver-
-
1Try to get element id or name by using the DevTools To access the DevTools, open a web page or web app in Google Chrome. Either: Select the Chrome menu Chrome Menu at the top-right of your browser window, then select Tools > Developer Tools. Right-click on any page element and select Inspect Element.– LraghawanCommented Feb 15, 2018 at 9:17
Add a comment
|
1 Answer
String userProfile= "C:\\Users\\user\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\";
System.setProperty("webdriver.chrome.driver","C:\\Users\\user\\Desktop\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir="+userProfile);
options.addArguments("--start-maximized");
WebDriver driver = new ChromeDriver(options);
driver.get("http://www.google.com");
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. It's quite cool.