Skip to content

Have .contains() strip new lines of targets. #92

@jennifer-shehane

Description

@jennifer-shehane

Description
Sometimes when I issue .contains() commands with text I expect to be found, it doesn't match my element as expected due to extra whitespace/new lines in my element.

Code

HTML

<h1>hello
world</h1>

Test

cy.contains("hello world") 
// CypressError: Timed out retrying: Expected to find content: 'hello world' but never did.

Web Page

screen shot 2015-12-11 at 12 05 02 pm

Additional Info

Checking jQuery's .text() in console, I see there is whitespace leading/trailing the actual text.

> $("h1").text()
> "hello
world"

Could it be possible to remove whitespace/new lines of el's when trying to match with .contains?

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomerspkg/driverThis is due to an issue in the packages/driver directorytype: unexpected behaviorUser expected result, but got another

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions