I want to write a test case in which I compare the value of an element clicked in previous page to that of an element's value in the current page.
I am using the following code -
validateText = SoftwaresUnmappedPage_POM.checkFirstSoftwareName.getText();
expect(validateText+"*").toBe(SoftwareSummary_POM.softwareName.getText());
For example - If I click on a button (ABC), then it loads a page. This page has elements indicating the element i clicked. But it displays the name as ABC*. So i want to verify if the element I clicked on and the page I am landing at is the same.
Error being caused - Expected '[object Object]' to be 'ABC'.
Can someone please help me resolve this problem? Thanks.
This won't work because Protractor works with promisses. You will first need to resolve the promise to be able to do what you want to test.
This will work
SoftwaresUnmappedPage_POM.checkFirstSoftwareName.getText()
// Get the resolved text from the promise
.then(function (validateText){
// Compare the result
expect(validateText+"*").toBe(SoftwareSummary_POM.softwareName.getText());
});
Hope this helps