Skip to content

Cypress not returning text on any element #31348

Open
@tonibwin

Description

@tonibwin

Current behavior

Note: Might be related to issue:

Cypress's invoke("text") is not returning ANY text from the application that is being tested. Cypress is able to capture and get the element on the page but when invoke("text") is chained afterwards, cypress throws an error. I have gone through the Cypress troubleshooting page and have cleared cache and cy folder but I am still running into this issue. Example below:

html content:

<span data-testid="product-name">Some text...</span>

spec content:

describe('basic test', () => {
  it('testing text', () => {
    cy.visit('https://127.0.0.1:8443/login')
    cy.get("[data-testid='product-name']").invoke("text").then(() => {
      cy.log("this command should run")
    })
  })
})

results:

Image

questions

  1. Based on the linked issue, could cypress malfunction, if certificates aren't provided or aren't correctly fetched?
  2. Could there be any security settings in my application, that could be causing cypress to not run as expected?

Desired behavior

Cypress should return "Some text..." after invoke("text") function has been executed on previously found element.

Test code to reproduce

html content:

<span data-testid="product-name">Some text...</span>

spec content:

describe('basic test', () => { it('testing text', () => { 
  cy.visit('https://127.0.0.1:8443/login') 
  cy.get("[data-testid='product-name']").invoke("text")
  .then(() => {  
     cy.log("this command should run") }) }) })

Cypress Version

14.2.0

Node version

v20.12.2

Operating System

Linux Ubuntu

Debug Logs

Other

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions