Reputation: 341
I am trying to access text of table data
using Selenium and then checking if it is equal to given text.
The problem I am facing is Expected result gets converted to Array with [] brackets
.
How can I convert this to basic string? What code change will help me achieve this?
Below is my code
const resultList = element.all(by.css('table tr:nth-of-type(9) [colspan]'));
expect(resultList.getText()).toEqual("This is data");
Output - Error
Expected [ 'This is data' ] to equal 'This is data'.
Trying to achieve (Without Brackets []
)
Expected 'This is data' to equal 'This is data'.
Upvotes: 2
Views: 54
Reputation: 1132
You can change your code to this -
expect(element(by.css('table tr:nth-of-type(9) [colspan]')).getText()).toEqual("This is test data.");
Upvotes: 1