Object is null

I am getting an error: Root cause: java.lang.IllegalArgumentException: Object is null, when trying to click on an element.

The Scenario:
Inside of an iframe I click a button that opens a new modal. The modal opens and is under the same iframe as the button that opened it. When I try to click on the button inside of the modal it then throws the above error.
What could be causing the null object error as it can clearly find the element but can not click on it? Using the web spy tool and I am able to verify that it is finding the element as well so I’m positive that it is getting the right element.

Chris Hollwedel said:

I am getting an error: Root cause: java.lang.IllegalArgumentException: Object is null, when trying to click on an element.

The Scenario:
Inside of an iframe I click a button that opens a new modal. The modal opens and is under the same iframe as the button that opened it. When I try to click on the button inside of the modal it then throws the above error.
What could be causing the null object error as it can clearly find the element but can not click on it? Using the web spy tool and I am able to verify that it is finding the element as well so I’m positive that it is getting the right element.

Hi Chris, did you ever resolve this? I have the same issue.

Did you ever resolve this? I have the same issue

Did anybody resolve this? I have the same issue

@jessica.jx.liu

Please share the execution log in the Console tab.

And here is the error log in console:
2020-08-25 16:00:38.918 INFO c.k.katalon.core.main.TestCaseExecutor - --------------------
2020-08-25 16:00:38.958 INFO c.k.katalon.core.main.TestCaseExecutor - START Test Cases/SearchAccountViaName
2020-08-25 16:00:40.464 DEBUG testcase.SearchAccountViaName - 1: openBrowser("")
2020-08-25 16:00:41.463 INFO c.k.k.core.webui.driver.DriverFactory - Starting ‘Chrome’ driver
Aug 25, 2020 4:00:41 PM org.openqa.selenium.remote.DesiredCapabilities chrome
INFO: Using new ChromeOptions() is preferred to DesiredCapabilities.chrome()
2020-08-25 16:00:41.563 INFO c.k.k.core.webui.driver.DriverFactory - Action delay is set to 0 milliseconds
Starting ChromeDriver 84.0.4147.30 (48b3e868b4cc0aa7e8149519690b6f6949e110a8-refs/branch-heads/4147@{#310}) on port 27444
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Aug 25, 2020 4:00:46 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
2020-08-25 16:00:46.306 INFO c.k.k.core.webui.driver.DriverFactory - sessionId = 4a1ea6188d257e63d58ca54bc560381c
2020-08-25 16:00:46.370 INFO c.k.k.core.webui.driver.DriverFactory - browser = Chrome 84.0.4147.135
2020-08-25 16:00:46.371 INFO c.k.k.core.webui.driver.DriverFactory - platform = Windows 10
2020-08-25 16:00:46.372 INFO c.k.k.core.webui.driver.DriverFactory - seleniumVersion = 3.141.59
2020-08-25 16:00:46.377 INFO c.k.k.core.webui.driver.DriverFactory - proxyInformation = ProxyInformation { proxyOption=NO_PROXY, proxyServerType=HTTP, username=, password=********, proxyServerAddress=, proxyServerPort=0, executionList="", isApplyToDesiredCapabilities=true }
2020-08-25 16:00:46.446 DEBUG testcase.SearchAccountViaName - 2: navigateToUrl(“https://producer-engage-wnins-apollo-dev2.api.dev-1.us-east-1.guidewire.net/producer-engage/new-quote-account-search”)
2020-08-25 16:00:52.034 DEBUG testcase.SearchAccountViaName - 3: setText(findTestObject(“Object Repository/Login/Page_guidewire-hub - Sign In/input_Username_username”), “jessica.j.liu@wnins.com”)
2020-08-25 16:00:55.751 DEBUG testcase.SearchAccountViaName - 4: click(findTestObject(“Object Repository/Login/Page_guidewire-hub - Sign In/input_Remember me_idp-discovery-submit”))
2020-08-25 16:00:56.329 DEBUG testcase.SearchAccountViaName - 5: setText(findTestObject("//[@id=“firstName”]"), “Demo”)
2020-08-25 16:00:56.330 WARN c.k.k.core.testobject.ObjectRepository - Test object with id 'Object Repository///
[@id=“firstName”]’ does not exist
2020-08-25 16:00:56.356 WARN c.k.k.core.testobject.ObjectRepository - Test object with id ‘Object Repository/’ does not exist
2020-08-25 16:01:02.538 ERROR c.k.k.core.keyword.internal.KeywordMain - :x: Unable to set text (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to set text
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26)
at com.kms.katalon.core.webui.keyword.builtin.SetTextKeyword.setText(SetTextKeyword.groovy:66)
at com.kms.katalon.core.webui.keyword.builtin.SetTextKeyword.execute(SetTextKeyword.groovy:37)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:73)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.setText(WebUiBuiltInKeywords.groovy:976)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$setText$1.call(Unknown Source)
at SearchAccountViaName.run(SearchAccountViaName:25)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:339)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:330)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:309)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:301)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:235)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1598342433335.run(TempTestCase1598342433335.groovy:25)
Caused by: java.lang.IllegalArgumentException: Object is null
at com.kms.katalon.core.helper.KeywordHelper.checkTestObjectParameter(KeywordHelper.java:33)
at com.kms.katalon.core.webui.keyword.builtin.SetTextKeyword$_setText_closure1.doCall(SetTextKeyword.groovy:45)
at com.kms.katalon.core.webui.keyword.builtin.SetTextKeyword$_setText_closure1.call(SetTextKeyword.groovy)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
at com.kms.katalon.core.webui.keyword.builtin.SetTextKeyword.setText(SetTextKeyword.groovy:66)
at com.kms.katalon.core.webui.keyword.builtin.SetTextKeyword.execute(SetTextKeyword.groovy:37)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:73)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.setText(WebUiBuiltInKeywords.groovy:976)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$setText$1.call(Unknown Source)
at Script1597825357275.run(Script1597825357275.groovy:25)
… 11 more
)
2020-08-25 16:01:02.552 ERROR c.k.katalon.core.main.TestCaseExecutor - :x: Test Cases/SearchAccountViaName FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to set text
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26)
at com.kms.katalon.core.webui.keyword.builtin.SetTextKeyword.setText(SetTextKeyword.groovy:66)
at com.kms.katalon.core.webui.keyword.builtin.SetTextKeyword.execute(SetTextKeyword.groovy:37)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:73)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.setText(WebUiBuiltInKeywords.groovy:976)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$setText$1.call(Unknown Source)
at SearchAccountViaName.run(SearchAccountViaName:25)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:339)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:330)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:309)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:301)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:235)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1598342433335.run(TempTestCase1598342433335.groovy:25)
Caused by: java.lang.IllegalArgumentException: Object is null
at com.kms.katalon.core.helper.KeywordHelper.checkTestObjectParameter(KeywordHelper.java:33)
at com.kms.katalon.core.webui.keyword.builtin.SetTextKeyword$_setText_closure1.doCall(SetTextKeyword.groovy:45)
at com.kms.katalon.core.webui.keyword.builtin.SetTextKeyword$_setText_closure1.call(SetTextKeyword.groovy)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
… 17 more

2020-08-25 16:01:02.594 INFO c.k.katalon.core.main.TestCaseExecutor - END Test Cases/SearchAccountViaName

@jessica.jx.liu

‘//*[@id=“firstname”]’ is the XPATH locator, not Katalon Test Object.
You can manually create a test object following this document: https://docs.katalon.com/katalon-studio/docs/manage-web-test-object.html#in-manual-view and put the above seletor to the Selected Locator field with the XPATH selector as the default locator then copy the test object ID and paste it to:

WebUI.setText(findTestObject('Put test object ID here'), 'Demo')

In case you want to create Katalon Test Object programmatically, you can write the script like this:

TestObject myNewObject = new TestObject('')
myNewObject.setSelectorValue(SelectorMethod.XPATH,'//*[@id="firstname"]')
myNewObject.setSelectorMethod(SelectorMethod.XPATH)
1 Like