The problem is that you are trying to click or add a class to a element that is not yet in the screen.
If you do something like in the image below it will solve that error you are having because the JS running asynchronously. You can read more here.
But this will not expand the dropdown, from my quick search online, see here, it appears expanding a dropdown (select) is not that simple... anyway you can try some of the solutions in that link ;)