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

"cy.type() failed because it targeted a disabled element" #6071

Closed
ghost opened this issue Dec 31, 2019 · 8 comments
Closed

"cy.type() failed because it targeted a disabled element" #6071

ghost opened this issue Dec 31, 2019 · 8 comments
Labels
type: duplicate This issue or pull request already exists

Comments

@ghost
Copy link

ghost commented Dec 31, 2019

Current behavior:

I'm getting a cypress error stating that the cy.type failed because it targeted a disabled element, which in my case is inside an iframe for the job description field. This is happening in version 3.8.0 and 3.8.1 of cypress. When I revert back to the 3.4.1 version of cypress the code works just fine.

image

Desired behavior:

For the test to be able to type in the iframe job description field which is not disabled.

Steps to reproduce: (app code and test code)

Versions

@jennifer-shehane
Copy link
Member

Unfortunately we have to close this issue as there is not enough information to reproduce the problem. This does not mean that your issue is not happening - it just means that we do not have a path to move forward.

Please comment in this issue with a reproducible example - the test code and the HTML to run the test code within - and we will reopen the issue.

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Jan 2, 2020
@ghost
Copy link
Author

ghost commented Jan 2, 2020

Test code is down below:

import '../../support/commands';

describe('Post a job', () => {
    beforeEach(() => {
        Cypress.on('window:before:load', (win: any) => {
            win.usabilla_live = win.usabilla_live || function() {};
        });
    });
    it('Post a job Classifieds', function() {
        const env = Cypress.env();
        cy.clearCookies();

        cy.login(env.usernameClassifieds, env.passwordClassifieds, env.employerUrl + '/job/');

        cy.get('#job-title').type(jobID_Alpha());
        function jobID_Alpha() {
            let text = 'Smoke test - Post a Job - ';
            const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';

            for (let i = 0; i < 5; i++) {
                text += possible.charAt(Math.floor(Math.random() * possible.length));
            }
            return text;
        }

        cy.get('[data-cy=google-location-search-input]').type('Des Moines');
        cy.get(':nth-child(1) > [data-cy=typeahead-option] > span').click();
        cy.get('#compensation-btn').click();
        cy.get('.pt-2 > :nth-child(1) > :nth-child(1)').click();
        cy.get('.pt-2 > :nth-child(2) > :nth-child(3)').click();
        cy.get('[data-cy=travelRequirements]').select('Occasional');

        cy.get('[data-cy=job-description] iframe').then(frame => {
            const iframe = frame.contents();
            const body = iframe.find('body p');
            body.attr('contenteditable', 'true');
            cy.wrap(body).type('test automation');
        });

        cy.get('.bg-light > .d-flex > .btn').click();
        cy.get('.rounded-pill > :nth-child(2)').click();
        cy.get('dhi-float-label-container.ng-tns-c24-6 > .float-label-container > .float-label-content > .form-control').clear();
        cy.get('dhi-float-label-container.ng-tns-c24-6 > .float-label-container > .float-label-content > .form-control').type(
            '[email protected]'
        );
        cy.get('#submitButton').click();

        // assertions
        cy.get('.post-job-btn > .d-none').should('contain', 'Post a Job');
        cy.logout();
    });
});

@ghost
Copy link
Author

ghost commented Jan 2, 2020

The test is designed for an angular application. The issue where the test is dying with cypress versions greater than 3.4.1 is the iframe job description field where it thinks it's disabled when in fact it's enabled. It's difficult to include all the details since the test is designed for an angular project. Let me know what else I can provide to help recreate the issue.

@ghost
Copy link
Author

ghost commented Jan 2, 2020

The part of the test that is throwing an error in cypress is:

cy.get('[data-cy=job-description] iframe').then(frame => {
        const iframe = frame.contents();
        const body = iframe.find('body p');
        body.attr('contenteditable', 'true');
        cy.wrap(body).type('test automation');
    });

@jennifer-shehane
Copy link
Member

@eabusharkh0 Yes, this last bit showing you type into the body of the iframe is helpful. Does the body have contenteditable? Because this may be a duplicate of this existing issue which was a regression in 3.5.0: #5930

@ghost
Copy link
Author

ghost commented Jan 2, 2020

It looks like it does, screenshot is below:
image

@ghost
Copy link
Author

ghost commented Jan 2, 2020

I see issue #5930 looks like the same issue as mine and it was found in 3.5.0, has it been fixed? Not sure why it works in version 3.4.1?

@jennifer-shehane
Copy link
Member

@eabusharkh0 No, it has not been fixed. That issue is still open. There was a change in 3.5.0 that broke this behavior. We suggest rolling back to 3.4.1 to have this work.

@jennifer-shehane jennifer-shehane added type: duplicate This issue or pull request already exists and removed stage: needs information Not enough info to reproduce the issue labels Jan 2, 2020
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

1 participant