@ashraf.madina I assume you are using the Script tab to display the text and so are familiar with that.
When I am working with dates, I use the following import statement at the top:
import groovy.time.TimeCategory /* to use Date library */
This gives me all the functionality for using format(), previous(), minus(n) and plus(n).
Not using XPath: The previous post I left counted the rows in the table, and then moved down the table row by row within a for() loop. Each “td” column within the row is stored within a List component that I named, Columns_row. Within each Columns_row, you want the Date Collected field. If the Date Collected field is the second column, then that would be Columns_row.get(1).getText() as the process is zero based ( 0 is column one, 1 is column two, etc). You haven’t shown any HTML, so I am making more assumptions. You can read up on how to move through tables on other KS questions. If you need to compare more than just the date field, then you can GETTEXT() of that field, like:
‘retrieve money from column 1 (zero based)’
moneyText = Columns_row.get(0).getText();
However, if you can get the XPath working, then you don’t need to move through the table.
If you can get the XPath to work, my thinking would be the Actual text would be from the Web page; the Expected text would be the value within the variable, “now”, as you have above. I save the web page text as “todaysDate”, like below:
def now = new Date().format(‘MM/dd/yyyy’);
def todaysDate = WebUI.getText(findTestObject(‘Page_Asset-Map Financials/td_dateCreated’));
WebUI.verifyMatch( todaysDate, now, false, FailureHandling.CONTINUE_ON_FAILURE)
I use this test of dates regularly and save my formatted date as a Global Variable.