首页 > 解决方案 > Web 自动化 - 如何将文本输入到由类定义的网站 (textarea) 上的富文本框中?

问题描述

我已经尝试了几天,完全被卡住了。如果有人可以帮助我,我将不胜感激;我正在使用 VB.NET。

HTML 代码:

    <tbody>
    <tr>
    <td class="chat-attachment-cell"><a href="#" id="attachment-link" class="attachment-link"></a></td> 
    <td class="chat-input-cell">

    <textarea class="chat-message-input"></textarea>

    </td> 
    <td class="chat-send-cell"><a href="#" class="chat-send-button"> alt="Send" width="66" height="66" border="0">
    </a>
    </td>
    </tr>
    </tbody>

我需要输入的文本框就是这个位

    <textarea class="chat-message-input"></textarea>

预先感谢您提供的任何帮助

标签: vb.netwebautomation

解决方案


您选择元素,然后根据需要更改 .innertext 属性。

有多种方法可以做到这一点,我不能给你一个例子,因为我不知道你在使用什么也不知道整个 html,但例如它可能看起来像这样:

WebBrowser1.Document.GetElementById("someid").InnerText="Sometext"

首先,您可以尝试查看您获得的元素集合的外观,然后您应该能够弄清楚下一步该做什么。

Dim test = WebBrowser1.Document.GetElementsByTagName("textarea")

例如在此页面上:

  Dim test = WebBrowser1.Document.GetElementsByTagName("tbody")
   test(1).InnerText = "Hi there"

在此处输入图像描述


推荐阅读