Skip to end of metadata
Go to start of metadata

During or after test executions, you may want to capture additional information about OS, browser, and screen resolution of the machine performing tests. Below are some sample custom keywords to help you with this task:

 

package com.mycompany

import regular.stuff.here

import org.openqa.selenium.Capabilities
import org.openqa.selenium.WebDriver
import org.openqa.selenium.remote.RemoteWebDriver
import com.kms.katalon.core.webui.driver.DriverFactory
import java.awt.*

public class GetTestingConfig {
@Keyword
def getOperatingSystem () {
	println System.getProperty('os.name')
}

@Keyword
def getBrowserAndVersion() {
	WebDriver driver = DriverFactory.getWebDriver()
	Capabilities caps = ((RemoteWebDriver) driver).getCapabilities()
	String browserName = caps.getBrowserName().capitalize()
	String browserVersion = caps.getVersion()
	println browserName + ' ' + browserVersion
}

@Keyword
def getScreenResolution() {
	Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize()
	Integer screenHeight = screenSize.height
	Integer screenWidth = screenSize.width
	println screenWidth + 'x' + screenHeight }
}

References: 

Credit to Drunda Ninbel

  • No labels