WebElement Not Found Error

Hello,

I am new on Katalon, and searched the forum little bit but could not find a solution. On my project, I have captured the xpath manually such as “//*[@id=“memberSearch”]” . Later tried with AbsoluteXpath.
However, I am getting an error as " Xpath is null" and my test fails. Later I wanted to try the new Self-Healing mode. I captured all the elements by using the spy mode. Every attempt to heal the element location also had failed. This element takes a little time to load inside a widget. I am using Katalon 7.6.1.

Any help will be appreciated.

This message is odd.

I have ever seen this message only once 2 years ago in a very old version Katalon Studio:

The problem was fixed already. The same problem has revived in Katalon 7.6.1 ? — not likely.

Could you show the fill log where you saw “Xpath is null” ?

I guess that error displays during execution. As I see now it shows the element cannot be located/found. I have tried to run the script until the widget is loaded with WebUI.waitForElementPresent(findTestObject(‘Object Repository/Dashboard/lookUpParticipantInputBox’), 5), but no luck.

Here is the log file
2020-07-27 16:26:40.751 INFO c.k.katalon.core.main.TestCaseExecutor - --------------------
2020-07-27 16:26:40.768 INFO c.k.katalon.core.main.TestCaseExecutor - START Test Cases/Plans/Verification_Plans_Tab_Default_Flow
2020-07-27 16:26:41.540 DEBUG t.Verification_Plans_Tab_Default_Flow - 1: comment(memberId)
2020-07-27 16:26:41.891 INFO c.k.k.c.keyword.builtin.CommentKeyword -
2020-07-27 16:26:41.892 DEBUG t.Verification_Plans_Tab_Default_Flow - 2: comment(" Logging with valid credentials for a Active member")
2020-07-27 16:26:41.897 INFO c.k.k.c.keyword.builtin.CommentKeyword - Logging with valid credentials for a Active member
2020-07-27 16:26:41.901 DEBUG t.Verification_Plans_Tab_Default_Flow - 3: login.Login.loginToMemberAccount(“6061814805”)
2020-07-27 16:26:41.908 WARN c.k.katalon.core.logging.KeywordLogger - Please use “KeywordUtil.logInfo()” instead of “new KeywordLogger()” constructor. “KeywordLogger” is an internal API and might be changed in the future.
2020-07-27 16:26:42.129 INFO c.k.k.core.webui.driver.DriverFactory - Starting ‘Chrome’ driver
Jul 27, 2020 4:26:42 PM org.openqa.selenium.remote.DesiredCapabilities chrome
INFO: Using new ChromeOptions() is preferred to DesiredCapabilities.chrome()
2020-07-27 16:26:42.173 INFO c.k.k.core.webui.driver.DriverFactory - Action delay is set to 0 milliseconds
Starting ChromeDriver 79.0.3945.36 (3582db32b33893869b8c1339e8f4d9ed1816f143-refs/branch-heads/3945@{#614}) on port 26860
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Jul 27, 2020 4:26:43 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
2020-07-27 16:26:43.359 INFO c.k.k.core.webui.driver.DriverFactory - sessionId = 89d28ba533fef3295194f484d3aaa043
2020-07-27 16:26:43.380 INFO c.k.k.core.webui.driver.DriverFactory - browser = Chrome 79.0.3945.130
2020-07-27 16:26:43.381 INFO c.k.k.core.webui.driver.DriverFactory - platform = Linux
2020-07-27 16:26:43.381 INFO c.k.k.core.webui.driver.DriverFactory - seleniumVersion = 3.141.59
2020-07-27 16:26:43.382 INFO c.k.k.core.webui.driver.DriverFactory - proxyInformation = ProxyInformation { proxyOption=NO_PROXY, proxyServerType=HTTP, username=, password=********, proxyServerAddress=, proxyServerPort=0, executionList="", isApplyToDesiredCapabilities=true }
2020-07-27 16:27:04.221 INFO c.k.k.c.webui.common.WebUiCommonHelper - Unable to find the element located by ‘By.xpath: //form[@id=‘participantSearchForm’]’. Please recheck the objects properties to make sure the desired element is located.
2020-07-27 16:27:04.224 WARN c.k.k.c.webui.common.WebUiCommonHelper - [SELF-HEALING] Failed to find element with id ‘Object Repository/Dashboard/lookUpParticipantInputBox’. Try using Self-healing.
2020-07-27 16:27:06.214 INFO c.k.k.c.webui.common.WebUiCommonHelper - [SELF-HEALING] Failed Locator: ‘//form[@id=‘participantSearchForm’]’.
2020-07-27 16:27:08.237 INFO c.k.k.c.webui.common.WebUiCommonHelper - [SELF-HEALING] Failed Locator: ‘//div[@id=‘participant-search-widget’]/div/div/form’.
2020-07-27 16:27:10.238 INFO c.k.k.c.webui.common.WebUiCommonHelper - [SELF-HEALING] Failed Locator: ‘(.//[normalize-space(text()) and normalize-space(.)=‘Participant Search’])[1]/following::form[2]’.
2020-07-27 16:27:12.233 INFO c.k.k.c.webui.common.WebUiCommonHelper - [SELF-HEALING] Failed Locator: '(.//
[normalize-space(text()) and normalize-space(.)=‘Drag a Widget Here’])[1]/following::form[2]’.
2020-07-27 16:27:14.195 INFO c.k.k.c.webui.common.WebUiCommonHelper - [SELF-HEALING] Failed Locator: ‘(.//[normalize-space(text()) and normalize-space(.)=‘Recent Participants’])[1]/preceding::form[1]’.
2020-07-27 16:27:17.092 INFO c.k.k.c.webui.common.WebUiCommonHelper - [SELF-HEALING] Failed Locator: '(.//
[normalize-space(text()) and normalize-space(.)=‘Participant Name’])[1]/preceding::form[1]’.
2020-07-27 16:27:19.206 INFO c.k.k.c.webui.common.WebUiCommonHelper - [SELF-HEALING] Failed Locator: ‘//div[2]/div/div/div/div/form’.
2020-07-27 16:27:21.216 INFO c.k.k.c.webui.common.WebUiCommonHelper - Unable to find the element located by ‘By.xpath: //[@id = ‘participantSearchForm’]’. Please recheck the objects properties to make sure the desired element is located.
2020-07-27 16:27:23.137 INFO c.k.k.c.webui.common.WebUiCommonHelper - Unable to find the element located by ‘By.cssSelector: #participantSearchForm’. Please recheck the objects properties to make sure the desired element is located.
2020-07-27 16:27:23.151 WARN k.k.c.w.k.b.WaitForElementPresentKeyword - Object ‘Object Repository/Dashboard/lookUpParticipantInputBox’ is not present after 5 second(s)
2020-07-27 16:27:23.153 INFO c.k.katalon.core.logging.KeywordLogger - Entering memberID into member search box
2020-07-27 16:27:55.185 INFO c.k.k.c.webui.common.WebUiCommonHelper - Unable to find the element located by ‘By.xpath: //form[@id=‘participantSearchForm’]’. Please recheck the objects properties to make sure the desired element is located.
2020-07-27 16:27:55.186 WARN c.k.k.c.webui.common.WebUiCommonHelper - [SELF-HEALING] Failed to find element with id ‘Object Repository/Dashboard/lookUpParticipantInputBox’. Try using Self-healing.
2020-07-27 16:27:57.179 INFO c.k.k.c.webui.common.WebUiCommonHelper - [SELF-HEALING] Failed Locator: ‘//form[@id=‘participantSearchForm’]’.
2020-07-27 16:27:59.195 INFO c.k.k.c.webui.common.WebUiCommonHelper - [SELF-HEALING] Failed Locator: ‘//div[@id=‘participant-search-widget’]/div/div/form’.
2020-07-27 16:28:01.207 INFO c.k.k.c.webui.common.WebUiCommonHelper - [SELF-HEALING] Failed Locator: '(.//
[normalize-space(text()) and normalize-space(.)=‘Participant Search’])[1]/following::form[2]’.
2020-07-27 16:28:03.199 INFO c.k.k.c.webui.common.WebUiCommonHelper - [SELF-HEALING] Failed Locator: ‘(.//[normalize-space(text()) and normalize-space(.)=‘Drag a Widget Here’])[1]/following::form[2]’.
2020-07-27 16:28:05.193 INFO c.k.k.c.webui.common.WebUiCommonHelper - [SELF-HEALING] Failed Locator: '(.//
[normalize-space(text()) and normalize-space(.)=‘Recent Participants’])[1]/preceding::form[1]’.
2020-07-27 16:28:07.186 INFO c.k.k.c.webui.common.WebUiCommonHelper - [SELF-HEALING] Failed Locator: ‘(.//[normalize-space(text()) and normalize-space(.)=‘Participant Name’])[1]/preceding::form[1]’.
2020-07-27 16:28:09.177 INFO c.k.k.c.webui.common.WebUiCommonHelper - [SELF-HEALING] Failed Locator: ‘//div[2]/div/div/div/div/form’.
2020-07-27 16:28:11.182 INFO c.k.k.c.webui.common.WebUiCommonHelper - Unable to find the element located by 'By.xpath: //
[@id = ‘participantSearchForm’]’. Please recheck the objects properties to make sure the desired element is located.
2020-07-27 16:28:13.181 INFO c.k.k.c.webui.common.WebUiCommonHelper - Unable to find the element located by ‘By.cssSelector: #participantSearchForm’. Please recheck the objects properties to make sure the desired element is located.
2020-07-27 16:28:13.338 ERROR c.k.k.core.keyword.internal.KeywordMain - :x: Unable to set text ‘6061814805’ of object ‘Object Repository/Dashboard/lookUpParticipantInputBox’ (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to set text ‘6061814805’ of object ‘Object Repository/Dashboard/lookUpParticipantInputBox’
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$0.call(Unknown Source)
at login.Login.loginToMemberAccount(Login.groovy:42)
at login.Login.invokeMethod(Login.groovy)
at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:50)
at Verification_Plans_Tab_Default_Flow.run(Verification_Plans_Tab_Default_Flow:26)
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 TempTestCase1595885197992.run(TempTestCase1595885197992.groovy:25)
Caused by: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: ‘Object Repository/Dashboard/lookUpParticipantInputBox’ located by ‘//form[@id=‘participantSearchForm’]’ not found
at com.kms.katalon.core.webui.common.WebUiCommonHelper.findWebElement(WebUiCommonHelper.java:1354)
at com.kms.katalon.core.webui.keyword.internal.WebUIAbstractKeyword.findWebElement(WebUIAbstractKeyword.groovy:27)
at com.kms.katalon.core.webui.keyword.internal.WebUIAbstractKeyword.findWebElement(WebUIAbstractKeyword.groovy:26)
at com.kms.katalon.core.webui.keyword.builtin.SetTextKeyword$_setText_closure1.doCall(SetTextKeyword.groovy:51)
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$0.call(Unknown Source)
at login.Login.loginToMemberAccount(Login.groovy:42)
at login.Login.invokeMethod(Login.groovy)
at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:50)
at Script1595608353157.run(Script1595608353157.groovy:26)
… 11 more
)
2020-07-27 16:28:13.342 ERROR k.k.c.m.CustomKeywordDelegatingMetaClass - :x: Unable to set text ‘6061814805’ of object ‘Object Repository/Dashboard/lookUpParticipantInputBox’
2020-07-27 16:28:13.344 ERROR c.k.katalon.core.main.TestCaseExecutor - :x: Test Cases/Plans/Verification_Plans_Tab_Default_Flow FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to set text ‘6061814805’ of object ‘Object Repository/Dashboard/lookUpParticipantInputBox’
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$0.call(Unknown Source)
at login.Login.loginToMemberAccount(Login.groovy:42)
at login.Login.invokeMethod(Login.groovy)
at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:50)
at Verification_Plans_Tab_Default_Flow.run(Verification_Plans_Tab_Default_Flow:26)
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 TempTestCase1595885197992.run(TempTestCase1595885197992.groovy:25)
Caused by: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: ‘Object Repository/Dashboard/lookUpParticipantInputBox’ located by ‘//form[@id=‘participantSearchForm’]’ not found
at com.kms.katalon.core.webui.common.WebUiCommonHelper.findWebElement(WebUiCommonHelper.java:1354)
at com.kms.katalon.core.webui.keyword.internal.WebUIAbstractKeyword.findWebElement(WebUIAbstractKeyword.groovy:27)
at com.kms.katalon.core.webui.keyword.internal.WebUIAbstractKeyword.findWebElement(WebUIAbstractKeyword.groovy:26)
at com.kms.katalon.core.webui.keyword.builtin.SetTextKeyword$_setText_closure1.doCall(SetTextKeyword.groovy:51)
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)
… 20 more

2020-07-27 16:28:13.349 INFO c.k.katalon.core.main.TestCaseExecutor - END Test Cases/Plans/Verification_Plans_Tab_Default_Flow

I can not see why because sufficient information not yet provided. Please have a look at the following guideline.

we would require full HTML page source, Test Object defintion, your test case script, and execution log. It is nice if the URL of your target web application is public and accessible for us,

I am working on my company’s internal web application. Please see the screenshots I have:

Xpath for search Button:

Xpath for searchTextBox:

Script:

SpyMode Capture textbox:
lookUpTextBox

SpyMode Capture LookUpButton:
lookupButton

Your HTML is simple enough. Your TestObjects seem to be OK. You showed just a part of test case script. I can not see if it is OK or not.

In the execution log, I could not find a log how your script navigated to the target URL. Possibly the Chrome browser is opened, but the test case script seems to be navigating to nowhere Does the test case script open the web page? Does you test case script include the lines like this ?

WebUI.openBrowser('')
WebUI.navigateToUrl('https://my.little.website')     // <-- do you have this ?
WebUI.verifyElementPresent(findTestObject('Object Repository/Dashboard/lookupParticipantInputBox'), 10)

I guess you are looking at a white empty screen because your script lacks a line of WebUI.navitateToUrl(...)

Well I am storing the website url in global variable then navigating. I have to login at the beginning. Everything works until I come to the widget after login. Then xpath cannot be found.

I can not find any more thing. I would give up, sorry.

Thanks for spending time to help. I hope someone can point out why Katalon errors out in this scenario.

I have actually tried to delay for a while. Later realized the widget is using JQuery. I used
WebUI.waitForJQueryLoad(20). Then I am getting an error : “This website don’t use jQuery.”
Still trying different approaches.

Hello @theautomater33, is it possible that the step you need before clicking on the button is not happening. you can check in your reports what is happening in the screenshots/videos.

Thanks

A wise man once said Katalon might not be able to capture, but Javascript will never be broken.

So here is the solution for someone who may have the same issue in the future:

  String js1="document.getElementById('participantSearch').value = " +GlobalVariable.memberId;
   WebElement element = WebUiCommonHelper.findWebElement(findTestObject('Your object'),20)
  WebUI.executeJavaScript(js1 , Arrays.asList(element))

Do not forget
import org.openqa.selenium.WebElement as WebElement
import com.kms.katalon.core.webui.common.WebUiCommonHelper as WebUiCommonHelper