ElementNotVisibleException when use headless Chrome browser

后端 未结 4 2520
慢半拍i
慢半拍i 2021-02-20 02:25

When I run test script in headless mode chrome browser, element link is not visible, is not able to do linkElement.click(). in head mode is everything OK. All other

4条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-20 02:59

    You can do this in two ways as below.

    1.Passing window size in chrome options as mentioned below(Before instantiating driver instance):

    ChromeOptions options = new ChromeOptions()
    options.addArguments("headless");
    options.addArguments("window-size=1200,1100");
    WebDriver driver = new ChromeDriver(options);
    

    2.Set window size after instantiating chrome driver:

    WebDriver webDriver= new ChromeDriver();
    webDriver.manage().window().setSize(new Dimension(1200,1100));
    

提交回复
热议问题