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.

Element is not visible, even though it should be

See original GitHub issue

Bug when trying to click a div element

Hi πŸ˜ƒ First of all thanks for a awesome service, really enjoy using and testing with cypress πŸ‘ However I have a issue with a test I’m writing, and I’m hoping maybe you can help me πŸ˜ƒ

Current behavior:

I have a calendar rendered in react, and try to click on one of the days (a div element rendered using flex-box layout). When running the cy.get('.rbc-today').click() command do I get the following error:

CypressError: Timed out retrying: cy.click() failed because this element is not visible:

<div class="rbc-day-bg rbc-today background-wrapper">...</div>

This element '<div.rbc-day-bg.rbc-today.background-wrapper>' is not visible because it has an effective width and height of: '0 x 0' pixels.

Fix this problem, or use {force: true} to disable error checking.

https://on.cypress.io/element-cannot-be-interacted-with

I have tried using click({ force: true}), and this does not raise a error, however the element is not clicked and the following commands fails because the click trigger a modal.

I have also tried adding cy.get('.rbc-today').should('be.visible') before the click command, without any luck. Only cy.wait(1000) works, but I would prefer not to use that.

My spec looks like this:

describe('Schedule planner', () => {
  before(() => {
    cy.loginAdmin()
  })

  it('allows the creation of shifts', () => {
    cy.visit('/schedules/1/edit')

    cy.get('.rbc-today').should('be.visible')

    cy.get('.rbc-today').click()

    cy.get('input[name="translations[en][name]"]')
      .type('A new shift')

    cy.get('input[name="attendanceLimit"]')
      .type(5)

    cy.get('input[name="startTime[time]"]')
      .type('10:00')

    cy.get('input[name="endTime[time]"]')
      .type('18:00')

    cy.get('button[type="submit"]').click()

    // TODO: assert some stuff
  })
})

Desired behavior:

The div element is visible in the snapshot, and has both width and height set if I inspect it, so cypress should not return this error, especially because cy.get('.rbc-today').should('be.visible') passes.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
lurajoncommented, Aug 29, 2018

@jennifer-shehane

Thank you for this awesome tool! I am a noob in Cypress at the moment, so this might be something I am doing wrong.

I have the same problem as @jokklan, but on a textarea. I have even added {force: true} to the cy.get(β€˜#org-description’).type(β€˜some random text’, {force:true});

This did however not make any difference to the test.

It has passed a few times, but have failed consistently lately. (same version of Cypress)

  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚ Cypress:    3.0.1                                                                              β”‚
  β”‚ Browser:    Electron 59 (headless)                                                             β”‚
  β”‚ Specs:      5 found (base/base_map_create_edit_spec.js, base/base_map_spec.js, base/orgAdmin_… β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
CypressError: Timed out retrying: cy.type() failed because this element is not visible:

<textarea name="org-description" id="org-description" class="form-control " required="required"></textarea>

This element '<textarea#org-description.form-control.>' is not visible because it has an effective width and height of: '0 x 0' pixels.

Fix this problem, or use {force: true} to disable error checking.

https://on.cypress.io/element-cannot-be-interacted-with

The screenshots clearly shows the textarea, so I find this strange. This only happens in headless mode.

orgadminhtml -- disable organisation

Best regards

Jone

1reaction
nevermore11184commented, Dec 7, 2019

Make sure, that you test it on the correct port. For instance, in my case it was Docker that kept an old DOM representation on :3000 port and my tests were running also on this port. It was solved by changing port on cypress.json - β€œbaseUrl”: β€œhttp://localhost:3001”.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Solve ElementNotVisibleException in Selenium ...
Solutions for ElementNotVisibleException in Selenium Webdriver ... First Solution: Try to write unique XPATH that matches with a single element ...
Read more >
Selenium Webdriver: Element Not Visible Exception
Webdriver may throw an ElementNotVisible exception in-case there are multiple elements with the same locator andΒ ...
Read more >
Element not visible- selenium error - SQA Stack Exchange
Element not visible exception can be resolved by using Explicit wait. Explicit wait in selenium will wait until the element is visible.
Read more >
Objects Are Not Visible - Revit - Autodesk Knowledge Network
Use this checklist to troubleshoot why objects are not visible in a view. Typically, when you cannot see an object as expected in...
Read more >
Element Present but Not Visible - Katalon Studio
so far, that line seems to sort of work, it will read that the element is present on the page, although it is...
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