Javascript:How to prevent Submit button getting disabled after dynamically inputting form text field?
I am triggering a popup on Swagger UI page load then setting the value of input field of Bearer token.and then wish to click on the 'Authorize' button programmatically to close the bearer token modal(Screenshot below).But the button seems disabled and unless I manually type something in the input it does not get enabled.What could be the issue?
window.addEventListener('load', function() {
// On Load tri开发者_如何转开发ggers Modal Popup
const authorizeButton = document.getElementsByClassName('authorize')[0];
authorizeButton.click();
//Set Input Field
const abcd = document.querySelectorAll('[aria-label="auth-bearer-value"]');
abcd[0].value = 'abcd';
abcd[0].dispatchEvent(new Event('change'));
abcd[0].dispatchEvent(new Event('keydown'));
abcd[0].dispatchEvent(new Event('keypress'));
abcd[0].dispatchEvent(new Event('keyup'));
abcd[0].dispatchEvent(new Event('input'));
// Need to Click on 'Authorize' button as shown in screenshot but it seems to be disabled
}
精彩评论