Capture and manipulate the error message from a failed test case
Runtime Options has 3 options -Halt On Failure, Continue On Failure, Continue with Pass status
it would be really great if there is an additional option added to handle the error message when any of the options are selected.
For example: If a test case failed with the error as web element is not found, I could use the error handler to customize the precise error message.
Hello Firas,
Use case: when "Get Web Value" command is used to pick any value from the web, and if the value is not found, the error message which is generated now as follows "Message Web element not found with '//table/tbody/tr/td[10]' no such element: Unable to locate element: method":"xpath","selector":"//table/tbody/tr/td[10]"}"
Proposed change: The current error message format is too technical, and I want to generate customized error message
To achieve this I'm proposing to add new feature at the Runtime Options, where if we select Halt On Failure a new message box should be displayed where we can enter the customized message.
Hope I explained the problem and proposal, please revert back if anything I missed
Hi Frioj, I just came across this post and wanted to share with you something I have personally used as a work around in our applications. :)
Option 1: Set GET_WEB_VALUE type as Number and wrap count() around x-path
a. This option gets row numbers, and you can compare them to other numbers or list of values in filters if needed.
Option 2: Set GET_WEB_VALUE type as Boolean, and get the element state (true or false)
b. This option gets the state of the element as true or false, and you can perform actions based upon the var set.
In your scenario I would probably be using count(//table/tbody/tr/td). However, if you need to see if [10] even exists, you will be able to see this in my example step 3 or 4. :)
Please copy this into the commands editor to view this sample test case solution for you.
WEB GOTO_URL "https://www.w3schools.com/html/html_tables.asp" HALT ON ERROR
WAIT 2 HALT ON ERROR
WEB VALUE_GET RESULT_VARIABLE State_OfRow7 SOURCE ELEMENT XPATH "(//*[@id='customers']//tbody/tr)[7]" ALIAS "" XML_TYPE "{http://www.w3.org/1999/XSL/Transform}BOOLEAN" ATTRIBUTE "TEXT" CAPTION "Check for Row 7" HALT ON ERROR
WEB VALUE_GET RESULT_VARIABLE State_OfRow8 SOURCE ELEMENT XPATH "(//*[@id='customers']//tbody/tr)[8]" ALIAS "" XML_TYPE "{http://www.w3.org/1999/XSL/Transform}BOOLEAN" ATTRIBUTE "TEXT" CAPTION "Check for Row 8" HALT ON ERROR
WEB VALUE_GET RESULT_VARIABLE Rows SOURCE ELEMENT XPATH "count(//*[@id='customers']//tbody/tr)" ALIAS "" XML_TYPE "{http://www.w3.org/1999/XSL/Transform}NUMBER" ATTRIBUTE "TEXT" CAPTION "Get Rows" HALT ON ERROR
IF @Rows GREATER "0" AS NUMBER
WRITE TEXT "ROWS GREATER THAN 0" OUTPUT CONSOLE CAPTION "ROWS GREATER THAN 0" HALT ON ERROR
ASSERT FALSE
IF_END
Sample of Option 1:
Sample of Option 2:
Showing Option 1 & Option 2 VAR Results:
Option 1: State_OfRow8 & State_OfRow7
Option 2: Rows
Please sign in to leave a comment.