Can't change headless window-size in project setting

For me, WebUI.SetViewPortSize worked for headless resizing. But adding window-size param to headless chrome in project setting does not work.

So strange! Could you please help?

It looks like an issue from using desired capabilities in Katalon interface. Workaround solution is using this custom code to handle window-size for Chrome (headless)

import org.openqa.selenium.WebDriver as WebDriver

import org.openqa.selenium.chrome.ChromeDriver as ChromeDriver

import org.openqa.selenium.chrome.ChromeOptions as ChromeOptions

import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory

import com.kms.katalon.core.webui.driver.WebUIDriverType as WebUIDriverType

if (DriverFactory.getExecutedBrowser() == WebUIDriverType.HEADLESS_DRIVER) {

System._setProperty_('webdriver.chrome.driver', DriverFactory._getChromeDriverPath_())



ChromeOptions options = **new** ChromeOptions()



options.addArguments('--headless', '--disable-gpu', 'window-size=200,300')



WebDriver driver = **new** ChromeDriver(options)



DriverFactory._changeWebDriver_(driver)

}

Vinh Nguyen said:

It looks like an issue from using desired capabilities in Katalon interface. Workaround solution is using this custom code to handle window-size for Chrome (headless)

import org.openqa.selenium.WebDriver as WebDriver

import org.openqa.selenium.chrome.ChromeDriver as ChromeDriver

import org.openqa.selenium.chrome.ChromeOptions as ChromeOptions

import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory

import com.kms.katalon.core.webui.driver.WebUIDriverType as WebUIDriverType

if (DriverFactory.getExecutedBrowser() == WebUIDriverType.HEADLESS_DRIVER) {

System._setProperty_('webdriver.chrome.driver', DriverFactory._getChromeDriverPath_())



ChromeOptions options = **new** ChromeOptions()



options.addArguments('--headless', '--disable-gpu', 'window-size=200,300')



WebDriver driver = **new** ChromeDriver(options)



DriverFactory._changeWebDriver_(driver)

}

I solved this problem by customized a browser based on chrome with params {"args":\["--headless","--window-size=1920,1080"\]}}

@Andy Zhang said:
Vinh Nguyen said:

It looks like an issue from using desired capabilities in Katalon interface. Workaround solution is using this custom code to handle window-size for Chrome (headless)

import org.openqa.selenium.WebDriver as WebDriver

import org.openqa.selenium.chrome.ChromeDriver as ChromeDriver

import org.openqa.selenium.chrome.ChromeOptions as ChromeOptions

import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory

import com.kms.katalon.core.webui.driver.WebUIDriverType as WebUIDriverType

if (DriverFactory.getExecutedBrowser() == WebUIDriverType.HEADLESS_DRIVER) {

 System.setProperty('webdriver.chrome.driver', DriverFactory.getChromeDriverPath())

 ChromeOptions options = new ChromeOptions()

 options.addArguments('--headless', '--disable-gpu', 'window-size=200,300')

 WebDriver driver = new ChromeDriver(options)

 DriverFactory.changeWebDriver(driver)

}

I solved this problem by customized a browser based on chrome with params {"args":["--headless","--window-size=1920,1080"]}}

Where should I put this piece of code?

!(file:///Users/yong/Desktop/Snip20180112_43.png)Zheng Li said:

@Andy Zhang said:

Vinh Nguyen said:

It looks like an issue from using desired capabilities in Katalon interface. Workaround solution is using this custom code to handle window-size for Chrome (headless)

import org.openqa.selenium.WebDriver as WebDriver

import org.openqa.selenium.chrome.ChromeDriver as ChromeDriver

import org.openqa.selenium.chrome.ChromeOptions as ChromeOptions

import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory

import com.kms.katalon.core.webui.driver.WebUIDriverType as WebUIDriverType

if (DriverFactory.getExecutedBrowser() == WebUIDriverType.HEADLESS_DRIVER) {

System.setProperty('webdriver.chrome.driver', DriverFactory.getChromeDriverPath())




ChromeOptions options = new ChromeOptions()




options.addArguments('--headless', '--disable-gpu', 'window-size=200,300')




WebDriver driver = new ChromeDriver(options)




DriverFactory.changeWebDriver(driver)

}

I solved this problem by customized a browser based on chrome with params {"args":["--headless","--window-size=1920,1080"]}}

Where should I put this piece of code?

In project → settings → execution → custom, then add a browser instance:

name: heasless_chrome (for example)
value: Chrome:  {"args":["--headless","--window-size=1920,1080"]}}

Hi, Can I put this in the profile so I can run it via Jenkins?