TestCase: Verify the table ROW contains text.

To verify text present in Table Row, i tried Using "expect.gettext().toContain(datefinal)".
But ouput returns "Expected '7/18/17' to contain undefined."

HTML Code:

<table class="table" width="100%" cellspacing="0" cellpadding="0">
     <tr class="tableheader">
     <td nowrap="true" align="left">
[email protected]</a>
      <td align="left">7/18/17</td>


 var dateString = "";
 var newDate = new Date();
 // Get the month, day, and year.
 dateString += (newDate.getMonth() + 1) + "/";
 dateString += newDate.getDate() + "/";
 dateString += newDate.getFullYear() - 2000;
 var datefinal = console.log(dateString);


Expected '7/18/17' to contain undefined.

2 Answers 2


You are assigning datefinal to the result of the console.log() call - which is undefined, hence the error. You meant to assert against dateString string:

  • I tried the above answer and it is giving me the below error Error: Invalid Chai property: toContain. Did you mean "contain"?
    – RRR
    Nov 14, 2018 at 12:37
  • (toConatin) is from Jasmine assertion library. It is correct.
    – Bustaq
    Nov 14, 2018 at 12:57

This is the function I've been working on. It takes an event name and searches for it in a grid (no paging to worry about). When found, returns the row# for use elsewhere.

verifyEventInGrid(eventName: string) {
        const names = element.all(by.className('ng-star-inserted'));
        names.count().then(function(count) {
            let rowFound = false;
            let i = 0;
            console.log('row count: ', count);
            names.get(i).getText().then(function(rowEventName) {
                do {
                    if (expect(rowEventName).toContain(eventName)) {
                        console.log(i, 'rowEventName:', rowEventName);
                        rowFound = true;
                        return i;
                } while (i <= count);
                console.log('row found:', i);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.