I am trying to autofill a drop-down selector, specifically on this website. Notice that when the user manually selects a country (let's say United Kingdom), the fields change and only postcode appears.
However, I'm a bit stuck on how to achieve this via JavaScript:
let pageElement = document.getElementById('#checkout_shipping_address_country');
pageElement.focus();
pageElement.value = "United Kingdom";
pageElement.dispatchEvent(new Event('change'));
pageElement.blur();
This only changes the value of the dropdown but somehow doesn't "submit" or "click" it as if a manual user is doing it. In other words, the State/PostCode fields don't dynamically change when another Country is selected.
I'm a bit stuck on how to proceed.