-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Comments
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. |
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();
});
}); |
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. |
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');
}); |
@eabusharkh0 Yes, this last bit showing you type into the body of the iframe is helpful. Does the |
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? |
@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. |
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.
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
The text was updated successfully, but these errors were encountered: