I am submitting this form 100 times a day and need to make it a little more efficient by automating the two first dropdown selections (everything else is already automated). I gave up in the past and I am almost giving up again now, as I am stuck on not getting it working. Been trying for 3 hours now.
document.getElementById('tux-2_button').selectedIndex = [...document.getElementById('tux-2_button').options].findIndex (option => option.text === "I’d like to report a possible copyright infringement in user-generated content")
returns TypeError: document.getElementById.options is not iterable
.
Testing with document.getElementById('tux-2_button').value
returns ''
no matter what option is selected.
document.getElementById('tux-2_button').textContent = "I’d like to report a possible copyright infringement in user-generated content"
changes the button text but does not trigger the event.
The DropdownButton does have an ID (‘tux-2_button’):
<button type="button" id="tux-2_button" aria-labelledby="tux-2_label tux-2_button" aria-haspopup="listbox" aria-controls="tux-2_list" aria-expanded="false" aria-invalid="false" class="css-1hneche"><div class="css-157g8iw">Select</div><div class="css-40sddq"></div><svg fill="currentColor" class="css-fdovmm" viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em"><path d="M24.71 32.03a1 1 0 0 1-1.58 0L14.4 20.6a1 1 0 0 1 .8-1.61h17.54a1 1 0 0 1 .79 1.61l-8.82 11.42Z"></path></svg></button>
Here are the selection options that are linked:
<ul id="tux-2_list" role="listbox" aria-labelledby="tux-2_label" tabindex="-1" class="css-9zaeqv"><li id="tux-2_list_1" role="option" aria-selected="false" data-list-item-value="1" class="css-1o2kt1p"><span>I’d like to report a possible copyright infringement in user-generated content</span></li><li id="tux-2_list_2" role="option" aria-selected="false" data-list-item-value="2" class="css-1o2kt1p"><span>Reporting a possible copyright infringement in advertisements or TikTok Shop</span></li><li id="tux-2_list_3" role="option" aria-selected="false" data-list-item-value="3" class="css-1o2kt1p"><span>Reporting a possible trademark infringement in user-generated content</span></li><li id="tux-2_list_4" role="option" aria-selected="false" data-list-item-value="4" class="css-1o2kt1p"><span>Found inappropriate content on TikTok</span></li><li id="tux-2_list_5" role="option" aria-selected="false" data-list-item-value="5" class="css-1o2kt1p"><span>Someone is impersonating me, sharing my private information, or featuring me in content on TikTok without my consent</span></li><li id="tux-2_list_6" role="option" aria-selected="false" data-list-item-value="6" class="css-1o2kt1p"><span>None of the above</span></li></ul>
Do you have some advice on how I can solve this?