Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$element.text is not a function #9435

Closed
VictorCapitole opened this issue Dec 3, 2020 · 4 comments
Closed

$element.text is not a function #9435

VictorCapitole opened this issue Dec 3, 2020 · 4 comments
Labels
type: duplicate This issue or pull request already exists

Comments

@VictorCapitole
Copy link

VictorCapitole commented Dec 3, 2020

I have this code:

cy.get(#element).should(($element) => {
        cy.log($element.text())
})

When running this code I have the following error: $element.text is not a function
But the log is printing the text properly.

image

@jennifer-shehane
Copy link
Member

So, for some reason the cy.log() is running twice here.

Duplicate of #8346

@VictorCapitole
Copy link
Author

It's not that.
I've changed the code to cy.get(loginForm.ddLanguage).text() and still have the same error.

image

@jennifer-shehane
Copy link
Member

jennifer-shehane commented Dec 3, 2020

@VictorCapitole This is because .text() is not a Cypress command, so it is not a function that can be chained off of Cypress commands.

See our FAQ for multiple ways to get the text of an element: https://on.cypress.io/using-cypress-faq#How-do-I-get-an-element%E2%80%99s-text-contents

You may want to try asking our community in our GitHub Discussions. As an open source project with a small maintainer team we have to focus our time on bugs and features in the product, which Issues are reserved for.

@DMazona
Copy link

DMazona commented Dec 27, 2021

I don't get it, the same page you reference mentions using .text() multiple times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants