Currently, I am in the process of creating a script for automating comments. During step one, I encountered an issue where the code is expected to simulate a click on this text area within a red box, but unfortunately nothing happened.
Initially, I attempted to use the code
document.getElementsByClassName("_ablz _aaoc")[0].click();
without success. It appears that the click() method only works on certain div tag elements within the webpage I am interacting with, presenting yet another challenge to tackle. Alternatively, I experimented with inserting the comment using
.value
, which did add text to the text area but left the "post" button disabled. To enable the button, it is necessary to click on the text area first and then produce at least one valid key press event before the post button becomes active. Refer to the image for illustration. Below is the HTML code relating to the text box and post button:
<textarea aria-label="Add a comment…" placeholder="Add a comment…" class="_ablz _aaoc" autocomplete="off" autocorrect="off" style="height: 18px !important;"></textarea>
<button class="_acan _acao _acas" type="submit" disabled=""><div class="_aacl _aaco _aacw _adda _aad0 _aad6 _aade">Post</div></button>
EDIT
Upon receiving recommendations to utilize .focus()
, I implemented this solution but experienced limitations when executing the action on the target website. Despite trying out
document.getElementsByClassName("_ablz _aaoc")[0].focus();
, the console returned 'undefined' and failed to focus the text area as intended.