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

should introduce a new `class LaunchedChromeDriver` class #22

Closed kazurayam closed 2 years ago

kazurayam commented 2 years ago

in https://github.com/kazurayam/webdriverfactory/blob/0.2.4/src/main/groovy/com/kazurayam/webdriverfactory/chrome/ChromeDriverFactoryImpl.groovy

there are lines:

            driver.metaClass.userProfile = Optional.of(cup)
            driver.metaClass.userDataAccess = Optional.of(instruction)

These lines are difficult to understand for those you do not know Groovy's Metaprogramming technique.

kazurayam commented 2 years ago

I have an idea: add a new class ChromeDriverLaunched, which is a composite of

  1. running ChromeDriver instance
  2. the DesiredCapabilities object which the ChromeDriver instance was launched with
  3. the ChromeUserProfile object which the ChromeDriver instance was launched with
  4. the UserDataAccess object which the ChromeDriver instance was launched with
class ChromeDriverLaunched {

    private final ChromeDriver chromeDriver
    private Optional<ChromeUserProfile> chromeUserProfile
    private Optional<UserDataAccess> instruction
    private Optional<DesiredCapabilities> employedDesiredCapabilities

    public ChromeDriverLaunched(ChromeDriver driver) {
        this.driver = driver
        this.chromeUserProfile = Optional.empty()
    }

    public ChromeDriver getDriver() {
        return this.driver
    }

    public ChromeDriverLaunched setChromeUserProfile(ChromeUserProfile cup) {
        this.chromeUserProfile = Optional.of(cup)
        return this    
    }

    public Optional<ChromeUserProfile> getChromeUserProfile() {
        return this.chromeUserProfile
    }

...
}
kazurayam commented 2 years ago

And most importantly, ChromeDriverFactory.newChromeDirver() should return an instance of ChromeDriverLaunched instead of ChromeDriver.

kazurayam commented 2 years ago

v0.2.6 supports this