Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't get the chromedriver default profile in java #1074

Open
GoogleCodeExporter opened this issue Jul 21, 2015 · 6 comments
Open

can't get the chromedriver default profile in java #1074

GoogleCodeExporter opened this issue Jul 21, 2015 · 6 comments

Comments

@GoogleCodeExporter
Copy link
Contributor

See http://goo.gl/ll2FvQ for common issues.

Issue Description:
<enter description here>

Steps to reproduce (if relevant, you MUST provide a simplified html page or
link to public site):
1. my code:
System.setProperty("webdriver.chrome.driver", "dir\\to\\my\\chromedriver.exe");
String userProfile= "C:\\Users\\heiq\\AppData\\Local\\Google\\Chrome\\User 
Data\\Default\\";
        ChromeOptions options = new ChromeOptions();
        options.addArguments("user-data-dir="+userProfile);
        WebDriver driver = new ChromeDriver(options);
2. it is expected to open a default browser with user data, but exactly open a 
clean browser.
3. my chromedriver log:
[1.140][INFO]: COMMAND InitSession {
   "desiredCapabilities": {
      "browserName": "chrome",
      "chrome.switches": [ "user-data-dir=C:\\Users\\heiq\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\", "--start-maximized" ],
      "chromeOptions": {
         "args": [ "user-data-dir=C:\\Users\\heiq\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\", "--start-maximized" ],
         "extensions": [  ]
      },
      "platform": "ANY",
      "version": ""
   }
}
[1.145][INFO]: Launching chrome: "C:\Program Files 
(x86)\Google\Chrome\Application\chrome.exe" --disable-background-networking 
--disable-client-side-phishing-detection --disable-component-update 
--disable-default-apps --disable-hang-monitor --disable-prompt-on-repost 
--disable-sync --disable-web-resources --enable-logging 
--ignore-certificate-errors 
--load-extension="C:\Users\heiq\AppData\Local\Temp\scoped_dir8536_32546\internal
" --logging-level=1 --metrics-recording-only --no-first-run 
--password-store=basic --remote-debugging-port=12352 
--safebrowsing-disable-auto-update --safebrowsing-disable-download-protection 
--start-maximized --use-mock-keychain 
--user-data-dir="C:\Users\heiq\AppData\Local\Google\Chrome\User Data\Default\\"
[1.454][INFO]: RESPONSE InitSession {
   "acceptSslCerts": true,
   "applicationCacheEnabled": false,
   "browserConnectionEnabled": false,
   "browserName": "chrome",
   "chrome": {
      "userDataDir": "C:\\Users\\heiq\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\"
   },
   "cssSelectorsEnabled": true,
   "databaseEnabled": false,
   "handlesAlerts": true,
   "javascriptEnabled": true,
   "locationContextEnabled": true,
   "nativeEvents": true,
   "platform": "Windows NT",
   "rotatable": false,
   "takesHeapSnapshot": true,
   "takesScreenshot": true,
   "version": "41.0.2272.101",
   "webStorageEnabled": true
}
4. my chromedriver's version: 2.10.267521; and my chrome's version: 
41.0.2272.101.
5. it works in firefoxdriver:
        ProfilesIni pi = new ProfilesIni();
        FirefoxProfile profile = pi.getProfile("default");
        WebDriver driver = new FirefoxDriver(profile);

-----Other helpful tips:
Attach your chromedriver log with verbose logging enabled (see
http://goo.gl/5Sx8mC for how to do this).

Original issue reported on code.google.com by summer20...@gmail.com on 5 Apr 2015 at 5:03

@GoogleCodeExporter
Copy link
Contributor Author

I am not able to reproduce the issue with latest version of chrome driver 2.14

Can you please try with the latest version?

Code-
ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir=/usr/local/google/home/gmanikpure/Documents/
profile");
WebDriver driver = new ChromeDriver(options);
driver.get("chrome://version");   // => Here i can see the correct profile path
Thread.sleep(5000);
driver.get("chrome://settings"); // => Here i see the correct preferences 
enabled

Original comment by gmanikp...@chromium.org on 6 Apr 2015 at 5:46

  • Added labels: Needs-Feedback

@GoogleCodeExporter
Copy link
Contributor Author

summer2014.lee@

if profile path is not correctly specified in {user-data-dir=} then driver will 
create new profile with mentioned name.
are you adding options.setBinary ("path to your chrome.exe")? to locate 
downloaded version of chrome. 

can you try with this simple script and let us know if issue reproduces.
and what do you mean by "it is expected to open a default browser with user 
data, but exactly open a clean browser." 


ChromeOptions options1 = new ChromeOptions();
options1.addArguments("--user-data-dir=C:\\Users\\name\\AppData\\Local\\Google\\
Chrome\\User Data\\Default");
    ChromeDriver driver1 = new ChromeDriver(options1);
     driver1.get("https://google.com");

Original comment by agau...@chromium.org on 5 May 2015 at 11:45

@GoogleCodeExporter
Copy link
Contributor Author

 summer2014.lee@

can you please reply to comment#2

Original comment by agau...@chromium.org on 28 May 2015 at 12:23

@GoogleCodeExporter
Copy link
Contributor Author

so sorry that I haven't logined my gmail until now.
my purpose is: when I logined some website the first time, I let the
browser remenber my username and password; when I open the website the
second time, I don't need to input my username and password. it is useful
for the automated testing when the website requires you to input a CAPTCHA,
because it makes you login derectly without input username and password.
my code is:
String userProfile= "C:\\Users\\heiq\\AppData\\Local\\Google\\Chrome\\User
Data";
ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir="+userProfile);
ChromeDriver driver = new ChromeDriver(options);
driver.get("chrome://settings");
when I close all the chrome browser, it works; when I leave a default
chrome browser open, it can't open the browser which remenbers my username
and password.
plz forgive my for my poor English.


Where there is a will there is a way.
Summer Lee

2015-05-28 20:23 GMT+08:00 <chromedriver@googlecode.com>:

Original comment by summer20...@gmail.com on 31 May 2015 at 2:25

@GoogleCodeExporter
Copy link
Contributor Author

You need to add Profile argument :- options.addArguments("--profile-directory= 
Profile 1");

Login in Profile 1 with your test gamil id and save userid and password, Form 
autofill data etc.. with this argument you can open same profile/browser which 
remember username and password.


           String userProfile= "C:\\Users\\heiq\\AppData\\Local\\Google\\Chrome\\User
            ChromeOptions options = new ChromeOptions();
            options.addArguments("--user-data-dir="+userProfile);
            options.addArguments("--profile-directory= Profile 1");
            ChromeDriver driver = new ChromeDriver(options);
            driver.get("chrome://version");


Let us know the result thanks.

Original comment by agau...@chromium.org on 26 Jun 2015 at 11:11

@GoogleCodeExporter
Copy link
Contributor Author

summer2014.lee

If we do not have multiple profiles we can ignore --profile-directory and 
mention --user-data-dir='C:/Users/<user>/AppData/Local/Google/Chrome/User 
Data', which takes default profile in the user data directory.

If we have multiple profiles in same user data directory, we need to specify 
which profile we want using --profile-directory='Profile 1'

can you please verify and let us know if you still facing the issue with latest 
chromedriver:2.16

Original comment by ssudunag...@chromium.org on 20 Jul 2015 at 8:04

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant