imacros: submitting textarea form (enter key maybe?)

浪尽此生 提交于 2019-11-28 12:25:05

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/41532248/imacros-submitting-textarea-form-enter-key-maybe

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!