Web element found by heuristic method is not used because we can't guarantee it reflects the intende

Hello, I have a problem with my automated tests, katalon does not recognize the iframe that contains the fields that I need to fill out and it shows me that it is not possible to find it and that it was found by a heuristic method, someone could help me, this is my log:

09-19-2018 10:30:57 AM - [START] - Start action : getWindowIndex

09-19-2018 10:30:57 AM - [INFO] - Getting current window’s index

09-19-2018 10:30:57 AM - [PASSED] - Current window’s index is: 1

09-19-2018 10:30:57 AM - [END] - End action : getWindowIndex

09-19-2018 10:30:57 AM - [START] - Start action : getWindowTitle

09-19-2018 10:30:57 AM - [INFO] - Getting current window’s title

09-19-2018 10:30:57 AM - [PASSED] - Current window’s title is: ‘Detalles’

09-19-2018 10:30:57 AM - [END] - End action : getWindowTitle

09-19-2018 10:30:57 AM - [START] - Start action : switchToWindowTitle

09-19-2018 10:30:57 AM - [INFO] - Checking title

09-19-2018 10:30:57 AM - [INFO] - Switching to window with title: ‘Detalles’

09-19-2018 10:30:58 AM - [PASSED] - Switched to window with title: ‘Detalles’

09-19-2018 10:30:58 AM - [END] - End action : switchToWindowTitle

09-19-2018 10:30:58 AM - [START] - Start action : mouseOver

09-19-2018 10:30:58 AM - [INFO] - Finding Test Object with id ‘Object Repository/Page_Detalles/input_nombreDelSolicitante’

09-19-2018 10:30:58 AM - [INFO] - Finding Test Object with id ‘Object Repository/Page_Detalles/div_Nombre del solicitante’

09-19-2018 10:30:58 AM - [INFO] - Finding Test Object with id ‘Object Repository/Page_Detalles/iframe_webForm’

09-19-2018 10:30:58 AM - [INFO] - Checking object

09-19-2018 10:30:58 AM - [INFO] - Object: ‘Object Repository/Page_Detalles/input_nombreDelSolicitante’ has parent object(s)

09-19-2018 10:30:58 AM - [INFO] - Switching to iframe: ‘Object Repository/Page_Detalles/iframe_webForm’

09-19-2018 10:30:58 AM - [INFO] - Checking timeout

09-19-2018 10:30:58 AM - [INFO] - Finding web element with id: ‘Object Repository/Page_Detalles/iframe_webForm’ located by ‘By.xpath: id(“webForm”)[count(. | //iframe[@id = ‘webForm’ and @title = ‘Carga Útil de Tarea’ and @src = ‘http://bpm-/frevvo/web/tn/designer/user/OZTXK5DJMVZHEZL2/app/_uC9qoK-lEeiOH4UQDUEU8Q/form/64c0b4f9-1918-4cbc-806b-c85a86688d38?typeId=_Yz2CgIYZEeip-I_OJS6lhw&locale=spa%2Ces&_formActionDocs=true&_wfuser=vgutierrez&_readonly=false&_formTz=Etc%2FGMT+6&embed=true&apikey=7NNzTnGwadoY276MwBs7yTAOKuHw1rrN2q5z9CRxAZB+DB7H7yiIqf5RbBSpBi3W’]) = count(//iframe[@id = ‘webForm’ and @title = ‘Carga Útil de Tarea’ and @src = ‘http://bpm-/frevvo/web/tn/designer/user/OZTXK5DJMVZHEZL2/app/_uC9qoK-lEeiOH4UQDUEU8Q/form/64c0b4f9-1918-4cbc-806b-c85a86688d38?typeId=_Yz2CgIYZEeip-I_OJS6lhw&locale=spa%2Ces&_formActionDocs=true&_wfuser=vgutierrez&_readonly=false&_formTz=Etc%2FGMT+6&embed=true&apikey=7NNzTnGwadoY276MwBs7yTAOKuHw1rrN2q5z9CRxAZB+DB7H7yiIqf5RbBSpBi3W’])]’ in ‘30’ second(s)

09-19-2018 10:31:30 AM - [INFO] - Found web element with id: ‘Object Repository/Page_Detalles/iframe_webForm’ using heuristic method. Matching attributes: [tag, id, title, frameborder, onload, _adfloaded, xpath].

09-19-2018 10:31:30 AM - [INFO] - Web element found by heuristic method is not used because we can’t guarantee it reflects the intended element.

09-19-2018 10:31:30 AM - [INFO] - You should consult our guide in choosing attributes : https://docs.katalon.com/x/fhlO

09-19-2018 10:31:30 AM - [FAILED] - Unable to move mouse over object ‘Object Repository/Page_Detalles/input_nombreDelSolicitante’ (Root cause: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: ‘Object Repository/Page_Detalles/iframe_webForm’ located by ‘By.xpath: id(“webForm”)[count(. | //iframe[@id = ‘webForm’ and @title = ‘Carga Útil de Tarea’ and @src = ‘http://frevvo/web/tn/designer/user/OZTXK5DJMVZHEZL2/app/_uC9qoK-lEeiOH4UQDUEU8Q/form/64c0b4f9-1918-4cbc-806b-c85a86688d38?typeId=_Yz2CgIYZEeip-I_OJS6lhw&locale=spa%2Ces&_formActionDocs=true&_wfuser=vgutierrez&_readonly=false&_formTz=Etc%2FGMT+6&embed=true&apikey=7NNzTnGwadoY276MwBs7yTAOKuHw1rrN2q5z9CRxAZB+DB7H7yiIqf5RbBSpBi3W’]) = count(//iframe[@id = ‘webForm’ and @title = ‘Carga Útil de Tarea’ and @src = ‘http://bpm-/frevvo/web/tn/designer/user/OZTXK5DJMVZHEZL2/app/_uC9qoK-lEeiOH4UQDUEU8Q/form/64c0b4f9-1918-4cbc-806b-c85a86688d38?typeId=_Yz2CgIYZEeip-I_OJS6lhw&locale=spa%2Ces&_formActionDocs=true&_wfuser=vgutierrez&_readonly=false&_formTz=Etc%2FGMT+6&embed=true&apikey=7NNzTnGwadoY276MwBs7yTAOKuHw1rrN2q5z9CRxAZB+DB7H7yiIqf5RbBSpBi3W’])]’ not found)

09-19-2018 10:31:30 AM - [END] - End action : mouseOver

09-19-2018 10:31:30 AM - [END] - End Test Case : Test Cases/Nueva Bodega

09-19-2018 10:31:30 AM - [FAILED] - Test Cases/Nueva Bodega FAILED because (of) Unable to move mouse over object ‘Object Repository/Page_Detalles/input_nombreDelSolicitante’ (Root cause: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: ‘Object Repository/Page_Detalles/iframe_webForm’ located by 'By.xpath: id(“webForm”)[count(. | //iframe[@id = ‘webForm’ and @title = ‘Carga Útil de Tarea’ and @src = ‘http://:7004/frevvo/web/tn/designer/user/OZTXK5DJMVZHEZL2/app/_uC9qoK-lEeiOH4UQDUEU8Q/form/64c0b4f9-1918-4cbc-806b-c85a86688d38?typeId=_Yz2CgIYZEeip-I_OJS6lhw&locale=spa%2Ces&_formActionDocs=true&_wfuser=vgutierrez&_readonly=false&_formTz=Etc%2FGMT+6&embed=true&apikey=7NNzTnGwadoY276MwBs7yTAOKuHw1rrN2q5z9CRxAZB+DB7H7yiIqf5RbBSpBi3W’]) = count(//iframe[@id = ‘webForm’ and @title = ‘Carga Útil de Tarea’ and @src = 'http://bpm-frevvo/web/tn/designer/user/OZTXK5DJMVZHEZL2/app/_uC9qoK-lEeiOH4UQDUEU8Q/form/64c0b4f9-1918-4cbc-806b-c85a86688d38?typeId=_Yz2CgIYZEeip-I_OJS6lhw&locale=spa%2Ces&_formActionDocs=true&_wfuser=vgutierrez&_readonly=false&_formTz=Etc%2FGMT+6&embed=true&apikey=7NNzTnGwadoY276MwBs7yTAOKuHw1rrN2q5z9CRxAZB+DB7H7yiIqf5RbBSpBi3W’])]’ not found)

thanks

1 Like

you need to simplify used xpath:
//iframe[@id = ‘webForm’ and @title = ‘Carga Útil de Tarea’]
should be enought (if id is unique)
my guess is that some parts of recorded xpath are generated on the fly each time page is reloaded

By the way, I am interested in the following line:

09-19-2018 10:31:30 AM - [INFO] - You should consult our guide in choosing attributes
: https://docs.katalon.com/x/fhlO

OK, I followed the link and found a Katalon Documentation titled “Optimizing Object Identification and Tools”.

It sais

3. Do not use attributes that can be changed when running on other environments such as hwdn, dynamic id, properties depending on screen resolution (width, height, x, y), etc.

If you take this guideline in mind and look back the XPath in the following message, you would agree that it is just terrible:

09-19-2018 10:30:58 AM - [INFO] - Finding web element with id: ‘Object Repository/Page_Detalles/iframe_webForm’ located by ‘By.xpath: id(“webForm”)[count(. | //iframe[@id = ‘webForm’ and @title = ‘Carga Útil de Tarea’ and @src = ‘http://bpm-/frevvo/web/tn/designer/user/OZTXK5DJMVZHEZL2/app/_uC9qoK-lEeiOH4UQDUEU8Q/form/64c0b4f9-1918-4cbc-806b-c85a86688d38?typeId=_Yz2CgIYZEeip-I_OJS6lhw&locale=spa,es&_formActionDocs=true&_wfuser=vgutierrez&_readonly=false&_formTz=Etc/GMT+6&embed=true&apikey=7NNzTnGwadoY276MwBs7yTAOKuHw1rrN2q5z9CRxAZB+DB7H7yiIqf5RbBSpBi3W’]) = count(//iframe[@id = ‘webForm’ and @title = ‘Carga Útil de Tarea’ and @src = ‘http://bpm-/frevvo/web/tn/designer/user/OZTXK5DJMVZHEZL2/app/_uC9qoK-lEeiOH4UQDUEU8Q/form/64c0b4f9-1918-4cbc-806b-c85a86688d38?typeId=_Yz2CgIYZEeip-I_OJS6lhw&locale=spa,es&_formActionDocs=true&_wfuser=vgutierrez&_readonly=false&_formTz=Etc/GMT+6&embed=true&apikey=7NNzTnGwadoY276MwBs7yTAOKuHw1rrN2q5z9CRxAZB+DB7H7yiIqf5RbBSpBi3W’])]’ in ‘30’ second(s)

As Andrej advised, the following xpath would be better and sufficient for you:

//iframe[@id = 'webForm' and @title = 'Carga Útil de Tarea']

Please be advised about the XPath which was automatically generated by Katalon Recorder + Spy. You should regard it as just a material which requires your review and refinement.

Hi again, I have done the test case again, using katalon 5.7 now, but still can not find the text field where it should be filled, now it returns the following error:

Test Cases/NuevaBodega FAILED because (of) (Stack trace: com.kms.katalon.core.exception.StepFailedException: Unable to set text ‘Victoria Gutierrez’ of object ‘Object Repository/Page_Detalles/input_Nombre del solicitante_n’ (Root cause: java.lang.IllegalArgumentException: Cannot find elements when the XPath expression is null.)

If you could help me, I would greatly appreciate it. :)

In order to find the reasen why ‘Root cause: java.lang.IllegalArgumentException: Cannot find elements when the XPath expression is null.’ occurs, we need to see the following:

  1. Screen shot that shows how ‘Object Repository/Page_Detalles/input_Nombre del solicitante_n’ is defined
  2. Screen shot of HTML source around the element which the above Test Object is targeted
  3. Your test case source
  4. whole log

Thank you very much for the support, I enclose what was requested in the message and really thank you.

Definicion_Nombredelsolicitante_n.JPG

htmlMombreSolicitante.JPG

Log.txt

Test Case.txt

html2.JPG

Victoria,

In the definition of the Test Object ‘Object Repository/Page_Detalles/input_Nombre del solicitante_n’, you have the radio-button ‘Parent iframe’ selected as follows:

Are you sure you have a Test Object ‘Object Repository/Page Detalles/iframe_webForm(1)’ and it is pointing

I ask this because the HTML screenshots you provided do not show the

victoria.jpg

Test Cases/NuevaBodega FAILED because (of) (Stack trace: com.kms.katalon.core.exception.StepFailedException: Unable to set text ‘Victoria Gutierrez’ of object ‘Object Repository/Page_Detalles/input_Nombre del solicitante_n’ (Root cause: java.lang.IllegalArgumentException: Cannot find elements when the XPath expression is null.)

Here is a message

Cannot find elements when the XPath expression is null.

This looks very odd. Why ‘null’ ? I can not see why at all.

This message makes me think that the Test Object ‘Object Repository/Page_Detalles/input_Nombre del solicitante_n’ is NOT yet fully properly acknowledged by Katalon Studio. (I am not sure, but for example Groovy source has been generated but not yet compiled …) If I am right, a possible countermeasure is to force Katalon Studio to acknowledge the definition of the Test Object and reprocess it.

Victoria,

Change the definition of the Test Object ‘Object Repository/Page_Detalles/input_Nombre del solicitante_n’ slightly; e.g., tick ‘tag’ on, as follows:

and save all, then run the test case again. I hope something may change.

add_tag.PNG

kazurayam said:

Victoria,

In the definition of the Test Object ‘Object Repository/Page_Detalles/input_Nombre del solicitante_n’, you have the radio-button ‘Parent iframe’ selected as follows:

Are you sure you have a Test Object ‘Object Repository/Page Detalles/iframe_webForm(1)’ and it is pointing

I ask this because the HTML screenshots you provided do not show the

Hello, I see that you are absolutely right, I went back to check the html and there is indeed an iframe, however the text fields are not inside, they are in another section called form with id = f1 and name = f1

How should I put it there?

captura_iframe.JPG

iframe.JPG

kazurayam said:

Test Cases/NuevaBodega FAILED because (of) (Stack trace: com.kms.katalon.core.exception.StepFailedException: Unable to set text ‘Victoria Gutierrez’ of object ‘Object Repository/Page_Detalles/input_Nombre del solicitante_n’ (Root cause: java.lang.IllegalArgumentException: Cannot find elements when the XPath expression is null.)

Here is a message

Cannot find elements when the XPath expression is null.

This looks very odd. Why ‘null’ ? I can not see why at all.

This message makes me think that the Test Object ‘Object Repository/Page_Detalles/input_Nombre del solicitante_n’ is NOT yet fully properly acknowledged by Katalon Studio. (I am not sure, but for example Groovy source has been generated but not yet compiled …) If I am right, a possible countermeasure is to force Katalon Studio to acknowledge the definition of the Test Object and reprocess it.

Victoria,

Change the definition of the Test Object ‘Object Repository/Page_Detalles/input_Nombre del solicitante_n’ slightly; e.g., tick ‘tag’ on, as follows:

and save all, then run the test case again. I hope something may change.

I tried it and it did not work; (

Hello again, I found another iframe and it is referred to by the code, however there is the text field to fill, sincerely I already lost in what happens with this problem

htmlfinal.JPG

Hello, I tell you that I managed to resolve the conflict, leaving the iframe registered only the id since having the others selected is not able to read it.

Infinite thanks for the help

solucion.JPG

Glad to hear it.