Jay Patel
Jay Patel

Reputation: 21

w2ui overlay is not rendered in cypress headless test

Test passes in headed mode, but always fails in headless mode

I am trying to perform a test on the w2ui field of type "list"

Ideally, when we click on this w2ui list element, a drop-down (overlay) is generated with the select options and then we select an option.

But while running the test in headless mode, this drop-down is not generated.

Code To reproduce the issue:-

Code for the webpage:

Link to HTML code

Save the code provided in the above link in the file "test_webpage.html". Place this HTML file in the directory where cypress.json is located.

Code of Cypress Test:

describe('W2UI List Test', function() {
      it('Click List Field', function() {
        cy.visit('test_webpage.html');
        cy.get('.w2ui-select').siblings('.w2ui-field-helper').should('be.visible').click();
        cy.wait(2000);
        cy.get('#w2ui-overlay tr[index=0]').should('be.visible').click();
    });
});

Test Fail ScreenShot

Upvotes: 2

Views: 531

Answers (1)

kuceb
kuceb

Reputation: 18043

Yes, there is a bug in Cypress currently where certain mouse events are not properly simulated when the Test Runner window is not the active window. This is being worked on here: https://github.com/cypress-io/cypress/issues/1909#issuecomment-395995180 , This is being worked on

In the meantime, you can change your test code to this, for example:

cy.get('.w2ui-select').siblings('.w2ui-field-helper').click()
cy.contains('Barack Obama').click()

Cypressautomatically checks for actionability before clicking, so no need for should('be.visible')

Upvotes: 0

Related Questions