Hello,
I’ve created a custom keyword for IE as below, but I’m getting the below error message, when I execute the test case in IE.
def static ie(def desiredCapabilities) {
DesiredCapabilities dc
WebUIDriverType executedBrowser = DriverFactory.getExecutedBrowser()
switch (executedBrowser) {
case WebUIDriverType.IE_DRIVER:
System.setProperty(“webdriver.ie.driver”, DriverFactory.getIEDriverPath())
for (item in desiredCapabilities) {
logger.logInfo(“Add " + item + " to IE”)
dc.setCapability(item.key, item.value)
}
dc.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true)
dc.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true)
dc.setCapability(“ignoreProtectedModeSettings”, true)
WebDriver driver = new InternetExplorerDriver(dc)
//Change current browser’s driver using new desired capabilities
DriverFactory.changeWebDriver(driver)
break
}
}
TEST CASE:
CustomKeywords.‘com.example.WebUICustomKeywords.ie’(null)
WebUI.navigateToUrl(GlobalVariable.G_SiteURL)
LOGS:
Test Cases/Common Test Cases/Login_Page_Open_Browser FAILED because (of) java.lang.NullPointerException: Cannot invoke method setCapability() on null object
com.example.WebUICustomKeywords.ie:112
com.example.WebUICustomKeywords.invokeMethod:0
Test Cases/Common Test Cases/Login_Page_Open_Browser.run:27
Could you please some one help me in order to execute my custom keyword in my test with above configurations?
I found the above code in internet but I do not understand exactly what will be the object and how I can use this keyword in my test cases.
Thanks in advance for your help.
Regards