kazurayam / chromedriverfactory

A Java library that enables you to launch Selenium ChromeDriver using an existing user Profile. That let you to carry cookies over multiple HTTP sessions via user Profile.
0 stars 0 forks source link

in DesiredCapabilites, found 2 "user-data-dir" ChromeOption #18

Closed kazurayam closed 2 years ago

kazurayam commented 2 years ago

I saw this:

DesiredCapabilities => {
    "acceptSslCerts": true,
    "browserName": "chrome",
    "goog:chromeOptions": {
        "args": [
            "window-size=1024,768",
            "--no-sandbox",
            "disable-infobars",
            "disable-gpu",
            "disable-dev-shm-usage",
            "--headless",
            "user-data-dir=/Users/kazuakiurayama/Library/Application Support/Google/Chrome",
            "profile-directory=Profile 6",
            "user-data-dir=/Users/kazuakiurayama/Library/Application Support/Google/Chrome",
            "profile-directory=Default"
        ],
        "extensions": [

        ],
        "prefs": {
            "plugins.plugins_disabled": [
                "Adobe Flash Player",
                "Chrome PDF Viewer"
            ],
            "profile.default_content_settings.popups": 0,
            "download.prompt_for_download": false,
            "download.default_directory": "/Users/kazuakiurayama/Downloads"
        }
    }
}

Notice, there are 2 user-data-dir and 2 profile-directory. This is bad. Which of profile-directory "Profile 6" and "Default" are actually used? Nobody knows.

Both of user-data-dir and profile-directory should appear only once in an instance of employed DesiredCapabilities.

kazurayam commented 2 years ago

v0.2.4, in the ChromeOptionsModifiers, it simple "appends" options into a ChromeOptions object.

This is bad.

It should check if user-data-dir option is already there or not. If is already there, it should replace it. If is not yet there, it should append it.

kazurayam commented 2 years ago

v0.2.4, in the ChromeDriverFactoryImpl, we have the following snippet

    private ChromeDriver launchChrome(Path userDataDir,
                                      ProfileDirectoryName profileDirectoryName,
                                      UserDataAccess instruction) {
    ...
        // use the specified UserProfile with which Chrome browser is launched
        ChromeOptionsModifier com =
                ChromeOptionsModifiers.withUserProfile(
                        targetUserDataDir,
                        profileDirectoryName.getName())
        this.addChromeOptionsModifier(com)

this causes duplicating "user-data-dir" and "profile-directory.