How to use seeTextEquals API?

I am facing issue with this API

seeTextEquals(p1, p2)

  1. If the provided text(p2) is empty string the test should return failure, but this function returning success while comparing with empty string. For example, if we compare ‘STANDARD DEFINITION OUTPUT’ with empty string (i.e. “ ”) the test is returning success.

  2. If the provided text(p2) is not complete string then test should return failure. But this function behavior is different, please looks at the below examples.

  • p1 = “STANDARD DEFINITION OUTPUT” p2 = “STANDARD DEFINITION OUTPUT” → Success
  • p1 = “STANDARD DEFINITION OUTPUT” p2 = “standard definition output” → Failure
  • p1 = “STANDARD DEFINITION OUTPUT” p2 = “SIMPLE” → Success
  • p1 = “STANDARD DEFINITION OUTPUT” p2 = “simple” → Failure
  • p1 = “STANDARD DEFINITION OUTPUT” p2 = “STANDARD” → Success
  • p1 = “STANDARD DEFINITION OUTPUT” p2 = “Standard” → Failure
  • p1 = “STANDARD DEFINITION OUTPUT” p2 = “S” → Success
  • p1 = “STANDARD DEFINITION OUTPUT” p2 = “DEFINITION OUTPUT” → Failure

So, this API is returning success if the first character of p2 is matching with the p1.

Is this API will check character by character or partial checking ?

Hey @Harini13 looks like you’re using the 3rd party assertions right?

Hi @peterngtr What you are meaning 3rd party assertion ?

I am using codecept API I.seeTextEquals to compare the string

Can you give idea what I.seeTextEquals API will do ?

@Harini13 Looks like you are passing the wrong arguments. Based on the documentation, the second argument is the context or other words the element you wanna check against

@peterngtr Yeah I have interchanged and given comments.
But even if I given proper argument in that case also its passing.

For eg : p1: DISCOVER p2: DISCHARGE

In this case also its passing

Even if I am given empty string to compare it is passing

@Harini13 based on the documentation, p1 is the text you wanna check. P2 is the context or element. If you don’t provide p2, it means it checks the text against the texts in webpage, if you provide p2 is an element for example h1. It means you wanna see the text equals with the text from h1.

@peterngtr So if both the text is same in that case only it have to pass right ?

@Harini13 If you want to check two strings, I don’t think this is the one you need. You can try some assertions lib like chai or expect

@peterngtr
I.seeTextEquals(menuStrings.menuLanguageSelectedOption[currentLangIndex], valConst.XPATH.menuLanguageSelectedOption);

menuStrings.menuLanguageSelectedOption[currentLangIndex] (p1)= ENGLISH
valConst.XPATH.menuLanguageSelectedOption (p2) = xpath (webelement)

If in the xpath the text p2 is “ENG” and my actual text p1 is “ENGLISH” it is passing

If in the xpath the text p2 is " " (empty string) and my actual text p1 is “ENGLISH” it is passing

can you tell me how I.seeTextEqual is working ?

@peterngtr
I want to use I.seeTextEqual in my script to compare the text .