Search code examples
imacros

imacros: submitting textarea form (enter key maybe?)


Question: How to simulate an ENTER (to submit a text in a live chat)? (if there is an alternative to using the ENTER key, like using javascript in imacros to trigger an event, that would be great too)


Explanation:

I am trying to submit a comment in a live chat that uses a <textarea> element for input. Here is the source code:

<form class="chatbox nolabel">
    <textarea class="textbox" type="text" size="70" autocomplete="off" name="message" style="resize: none; overflow-y: hidden;"></textarea>
</form>

I have attempted various different approaches of inputting the word "hello" and pressing the ENTER key (so that hello is sent to the users reading), however the only thing I am capable of doing is inputting the word "hello".

Attempt 1:

TAG POS=1 TYPE=TEXTAREA FORM=NAME:NoFormName ATTR=NAME:message CONTENT=hi

Results from Attempt 1: When recording, this is the code that appeared when I started typing in the text area, and it successfully places the content into the textarea, however I didn't see any code being recorded when I press the ENTER key, so I assume that is the issue in this case.

Attempt 2: (event recording mode)

EVENTS TYPE=KEYPRESS SELECTOR="HTML>BODY>DIV:nth-of-type(2)>DIV>DIV>DIV>DIV>DIV>DIV:nth-of-type(2)>FORM>TEXTAREA:nth-of-type(2)" CHARS="hi"
WAIT SECONDS=1
EVENT TYPE=KEYPRESS SELECTOR="HTML>BODY>DIV:nth-of-type(2)>DIV>DIV>DIV>DIV>DIV>DIV:nth-of-type(2)>FORM>TEXTAREA:nth-of-type(2)" KEY=13

Results from Attempt 1: In this case, I tried using the Keypress type with events to simulate hitting the ENTER key, however what resulted was getting a "hi(newline)".

Any ideas?


Solution

  • Sometimes other key event types may help:

    EVENT TYPE=KEYDOWN SELECTOR="HTML>BODY>DIV:nth-of-type(2)>DIV>DIV>DIV>DIV>DIV>DIV:nth-of-type(2)>FORM>TEXTAREA:nth-of-type(2)" KEY=13
    

    or

    EVENT TYPE=KEYUP SELECTOR="HTML>BODY>DIV:nth-of-type(2)>DIV>DIV>DIV>DIV>DIV>DIV:nth-of-type(2)>FORM>TEXTAREA:nth-of-type(2)" KEY=13