Hi, I use this plugin to automatically fill a form on a website. The problem is that the options appear in order, that is, option B appears after choosing option A. It also seems to me that the options must be selected by click, not by code.
I used the plugin's own guide, but it didn't help.
Can you think of a solution?
My Java Code:
var menu1 = document.getElementById('city');
var menu2 = document.getElementById('office');
var menu3 = document.getElementById('officetype');
menu1.dispatchEvent(new Event('mousedown'));
menu1.dispatchEvent(new Event('mouseup'));
// Replace 'option_a' and 'option_b' with the actual values of the options you want to select
menu1.value = '1';
menu1.dispatchEvent(new Event('change'));
// Simulate a mouse click event on the menu to trigger the appearance of options
menu2.dispatchEvent(new Event('mousedown'));
menu2.dispatchEvent(new Event('mouseup'));
// Wait for the dependent dropdown to update
setTimeout(function() {
// Replace 'option_x' with the desired option value from Menu 2
var optionToSelect = '1';
var option = Array.from(menu2.options).find(function (opt) {
return opt.value === optionToSelect;
});A
if (option) {
option.selected = true;
menu2.dispatchEvent(new Event('change'));
}
}, 1000);
// Repeat this process for subsequent dropdowns if needed