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

make TilingWindowLayoutMetrics simpler, make StackingWindowLayoutMetrics easier to use #13

Closed kazurayam closed 2 years ago

kazurayam commented 2 years ago

Currently I code like this

    @Test
    void test_open2windows_in_tiling_layout() {
        List<WindowLocation> locations = [
                new WindowLocation(2, 0),
                new WindowLocation(2, 1),
        ]
        ChromeDriverFactory factory = ChromeDriverFactory.newChromeDriverFactory()
        ChromeDriver browser0 = factory.newChromeDriver(new UserProfile("Picasso"))
        BrowserWindowLayoutManager.layout(browser0,
                tilingLayout.getWindowPosition(locations.get(0)),
                tilingLayout.getWindowDimension(locations.get(0)))
        ChromeDriver browser1 = factory.newChromeDriver(new UserProfile("Gogh"))
        BrowserWindowLayoutManager.layout(browser1,
                tilingLayout.getWindowPosition(locations.get(1)),
                tilingLayout.getWindowDimension(locations.get(1)))
        browser0.navigate().to("https://www.pablopicasso.org/")
        browser1.navigate().to("https://www.vincentvangogh.org/")
        Thread.sleep(1000)
        browser0.quit()
        browser1.quit()
    }        

I find this is difficult. I want this changed like the following

    @Test
    void test_open2windows_in_tiling_layout() {
        List<WindowLocation> locations = [
                new WindowLocation(2, 0),
                new WindowLocation(2, 1),
        ]
        TilingWindowLayoutMetrics layoutMetrics =
                new TilingWindowLayoutMetrics.Builder(locations).build()
        ChromeDriverFactory factory = ChromeDriverFactory.newChromeDriverFactory()
        ChromeDriver browser0 = factory.newChromeDriver(new UserProfile("Picasso"))
        BrowserWindowLayoutManager.layout(browser0, layoutMetrics.get(0))
        ChromeDriver browser1 = factory.newChromeDriver(new UserProfile("Gogh"))
        BrowserWindowLayoutManager.layout(browser1, layoutMetrics.get(1))
        browser0.navigate().to("https://www.pablopicasso.org/")
        browser1.navigate().to("https://www.vincentvangogh.org/")
        Thread.sleep(1000)
        browser0.quit()
        browser1.quit()
    }