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

ChromeDriverFactoryImpl#launchChrome is not tested enough #16

Closed kazurayam closed 2 years ago

kazurayam commented 2 years ago

ChromeDriverFactoryImple class has the following snippet

private ChromeDriver launchChrome(ChromeUserProfile userProfile,
                                      Path originalProfileDirectory,
                                      Path userDataDir,
                                      ProfileDirectoryName profileDirectoryName,
                                      UserDataAccess instruction) {
        if (instruction == UserDataAccess.TO_GO) {
            // create a temporary directory with name "User Data", into which
            // copy the Profile directory contents from the Chrome's internal "User Data",
            // this is done in order to workaround "User Data is used" contention problem.
            userDataDir = Files.createTempDirectory("__user-data-dir__")
            Path destinationDirectory = userDataDir.resolve(profileDirectoryName.getName())
            PathUtils.copyDirectoryRecursively(
                    originalProfileDirectory,
                    destinationDirectory)
            int numCopied = PathUtils.listDirectoryRecursively(destinationDirectory).size()
            logger_.info("copied ${numCopied} files from ${originalProfileDirectory} into ${destinationDirectory} ")
        } else {
            logger_.debug("will use ${originalProfileDirectory} ")
        }

This snippet copies the contents of a Profile directory from the genuin user-data-dir to a temporary user-data-dir.

But this code is not well-tested.

And I have a doubt it is buggy. I found a case where the Cookie file is not copied properly. I should make sure.