You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
WebDriver 5: seeTextEquals passes for any string if element is empty #1561
Let's say now there is no value in p.
So I.seeTextEquals("Authentication failed.", ".error.message"); should fail.
What do you get instead?
Provide console output if related. Use --verbose mode for more details.
This test passes:
Emitted | step.start (I see text equals "Authentication failed.", ".error.message")
I see text equals "Authentication failed.", ".error.message"
› [SmartWait (20000ms)] Locating .error.message in 20000
Emitted | step.passed (I see text equals "Authentication failed.", ".error.message")
Emitted | step.finish (I see text equals "Authentication failed.", ".error.message")
Emitted | step.start (I see text equals "Authentication failed.", ".error.message")
I see text equals "Authentication failed.", ".error.message"
› [SmartWait (20000ms)] Locating .error.message in 20000
[1] Error | Error: expected element .error.message "Authentication failed." to equal ""
Emitted | step.failed (I see text equals "Authentication failed.", ".error.message")
Emitted | step.finish (I see text equals "Authentication failed.", ".error.message")
[1] Error | Error: expected element .error.message "Authentication failed." to equal ""
Test --
abc,
✖ Test @test in 12252ms
-- FAILURES:
1) Test
Test @test:
expected element [id="site-logo"] "abc" to equal ""
Scenario Steps:
- I.seeTextEquals("abc", "[id="site-logo"]") at Test.Scenario (tests/smokeCheck/linkedin.js:20:5)
- I.amOnPage("https://codecept.discourse.group/") at Test.Scenario (tests/smokeCheck/linkedin.js:19:5)
Run with --verbose flag to see NodeJS stacktrace
FAIL | 0 passed, 1 failed // 13s
@peterngtr, I've upgraded CodeceptJS to 2.0.8 and my test started failing. I.seeTextEquals doesn't work with empty string.
An example how to reproduce it:
-- FAILURES:
1) My
One:
expected element #ember7 "" to equal ""
Scenario Steps:
- I.seeTextEquals("", "#ember7") at Test.Scenario (My_test.js:7:7)
- I.amOnPage("https://codecept.discourse.group/") at Test.Scenario (My_test.js:6:7)
It fails with webdriverio@5 and passes with webdriverio@4
@mirao sorry, the last patch didn't work properly. I found the root cause, the problem is when codeceptjs try to get the text from the locator, it returns the array
const selected = await forEachAsync(res, async el => this.browser.getElementText(getElementId(el)));
In this case, the locator has no text it returns an empty array. However the the text you want to compare is a string. And the equals method is
const comparator = function (a, b) {
return a === b;
};
and by this, it returns false, even though both are empty but one is string, one is array.
Activity
mirao commentedon Mar 13, 2019
Correct behavior is with WebDriver 4:
kobenguyent commentedon Mar 14, 2019
Found the issue and fixed it -> #1564
mirao commentedon Mar 22, 2019
@peterngtr, I've upgraded CodeceptJS to 2.0.8 and my test started failing.
I.seeTextEqualsdoesn't work with empty string.An example how to reproduce it:
It fails with webdriverio@5 and passes with webdriverio@4
kobenguyent commentedon Mar 23, 2019
Well, I’ll take a look @mirao
kobenguyent commentedon Mar 23, 2019
@mirao sorry, the last patch didn't work properly. I found the root cause, the problem is when codeceptjs try to get the text from the locator, it returns the array
In this case, the locator has no text it returns an
empty array. However the the text you want to compare is astring. And theequalsmethod isand by this, it returns
false, even though both are empty but one isstring, one isarray.Last but not least, fix is here -> #1576
mirao commentedon Apr 1, 2019
OK, thanks for your effort. I guess it will be released in 2.0.9, am I right?
kobenguyent commentedon Apr 1, 2019
I guess so if it’s merged soon by @DavertMik
mirao commentedon Dec 7, 2019
It works well with CodeceptJS 2.3.6, WebDriverIO 5.16.13