question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WebDriver 5: seeTextEquals passes for any string if element is empty

See original GitHub issue

It works as expected with WebDriver 4 and doesn’t work with WebDriver 5.

What are you trying to achieve?

I want to test if the exact text “Authentication failed.” appears in the p subelement of

<div class="ui error message">
  <div class="content">
    <p></p>
  </div>
</div>

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")

Provide test source code if related

    I.seeTextEquals("Authentication failed.", ".error.message");

Details

  • CodeceptJS version: 2.0.7
  • NodeJS Version: 10.15.1
  • Operating System: Ubuntu 18.10
  • WebDriver: 5.7.2
  • Configuration file:
exports.config = {
    tests: "./*_test.js",
    output: "./output",
    helpers: {
        WebDriver: {
            url: "http://localhost",
            browser: process.profile || "chrome",
            waitForTimeout: 20000,
            smartWait: 20000
        }
    },
    include: {
        I: "./steps_file.js"
    },
    bootstrap: null,
    mocha: {},
    name: "demo"
};

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
PeterNgTrcommented, Mar 14, 2019

Found the issue and fixed it -> https://github.com/Codeception/CodeceptJS/pull/1564

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
0reactions
miraocommented, Dec 7, 2019

It works well with CodeceptJS 2.3.6, WebDriverIO 5.16.13

Read more comments on GitHub >

github_iconTop Results From Across the Web

WebDriver 5: seeTextEquals passes for any string if element is ...
I want to test if the exact text "Authentication failed. ... WebDriver 5: seeTextEquals passes for any string if element is empty #1561....
Read more >
I want to pass my test if the element in selenium returns empty ...
logger.info("The text is "+ element.getText()); Assert. ... You can use Assertions to fail the case if string is not empty.
Read more >
WebDriver - CodeceptJS
Attaches a file to element located by label, name, CSS or XPath Path to file is relative current codecept directory (where codecept.conf.ts or ......
Read more >
WebElement..getText() sometimes returns empty string when ...
I am finding that WebElement.getText() returns an empty string sometimes, but when it happens and I take a screenshot, the text is there....
Read more >
Waits - Selenium
An implicit wait is to tell WebDriver to poll the DOM for a certain amount of time when trying to find an element...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found