There is one case that, when i open the URL manually in chrome browser and give the credentials. After clicking on sign in button one OTP will come to mobile. There is one checkbox after entering the OTP. Don't ask OTP for this browser. If we click on that check box and login into the portal. Then from next time if we open same browser and access the portal, it will not ask for OTP. So can we automatically open same browser every time after closing browser. Without calling new chrome instance.
Asked
Active
Viewed 736 times
0
-
Can you change the OTP option to Authenticator? What happens when you open a new browser manually after completing the OTP, still does it ask for OTP again? – supputuri Jul 16 '20 at 11:55
-
when you we use webdriver, it will create every time new instance and it will open new chrome. For this case every time OTP is asking. So when i open local installed chrome then only one time it will ask for OTP. – Praveen Kumar Reddy Jul 16 '20 at 12:14
-
Ok, then you can open the local chrome profile as part of your execution so that you don't get the OTP request again. Please refer to [this](https://stackoverflow.com/questions/56344560/selenium-point-towards-default-chrome-session/56402113#56402113) post – supputuri Jul 16 '20 at 12:26
1 Answers
0
You can use the default profile to use the local chrome profile once the OTP is completed manually.
ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir=/path/to/your/custom/profile");
ChromeDriver driver = new ChromeDriver(options);
You can get the default profile path as shown in the below screenshot.
Please open
chrome://version
in the browser to see what profile Chrome is using.

supputuri
- 13,644
- 2
- 21
- 39
-
public class Test{ public static void main(String args[]){ System.setProperty("webdriver.chrome.driver","C://Program Files (x86)//Google//Chrome//Application//chrome.exe"); ChromeOptions options = new ChromeOptions(); options.addArguments("user-data-dir=C:\Users\user-name\AppData\Local\Google\Chrome\User Data\Default"); ChromeDriver driver = new ChromeDriver(options); WebDriver driver = new ChromeDriver(); String baseurl = "http://www.facebook.com/"; driver.get(baseurl); } } – Praveen Kumar Reddy Jul 16 '20 at 14:17
-
This code is not working. I tried with above approach. Can you please modify if any error. – Praveen Kumar Reddy Jul 16 '20 at 14:18
-
First thing first, is facebook your application under test or just trying with it? Check the facebook rules, if you can use automation on their web page, it might be against their rules. – supputuri Jul 16 '20 at 14:20
-
Have you got the `user-data` path from the chrome://version browser where you completed OTP? Did you got any error message? – supputuri Jul 16 '20 at 14:22
-
Facebook is not my application which i am doing. I just given example URL there instead of my original URL. Should i can take like this?? System.setProperty("webdriver.chrome.driver","C://Program Files (x86)//Google//Chrome//Application//chrome.exe"); Because With this path chrome is opening but URL is not passing. – Praveen Kumar Reddy Jul 17 '20 at 03:40
-
After URL issue got resolved, then i can get the user-data profile once completed the OTP step. – Praveen Kumar Reddy Jul 17 '20 at 03:42