2

我正在寻找一些解决方案,例如 Selenium WebDriver:

ChromeOptions options = new ChromeOptions();options.addArgument("--start-maximized");

所以在执行测试时浏览器窗口应该最大化。

我为这个问题找到了一个基于配置文件的解决方案,但它打开了很多标签,这可能是由转义字符引起的。

@Test
    public void chromeWithProfileLaunch() throws Exception {
        String profileDir = "--user-data-dir=\"c:\\Temp\\profile1\""; //should be different folder every time
        String leanftChromeExtension = "--load-extension=C:\\Program Files (x86)\\HPE\\LeanFT\\Installations\\Chrome\\Extension"; //to load the LeanFT extension
        String homePage = "www.google.com"; //the homepage to start with

        new ProcessBuilder("C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe", profileDir, leanftChromeExtension, homePage)
            .start();

        Thread.sleep(2000); //wait for Chrome process to load

        Browser openedBrowser = BrowserFactory.attach(new BrowserDescription.Builder().title("Google").type(BrowserType.CHROME).build());

        Verify.areEqual(homePage, openedBrowser.getURL());
    }
4

2 回答 2

1
于 2018-05-14T13:13:28.270 回答
1

我不知道最大化,但 LeanFT 支持将浏览器置于fullScreenmode

于 2018-05-14T09:07:26.030 回答