gpt4 book ai didi

javascript - 无法使用 .net 在网页中单击“提交”按钮

转载 作者:行者123 更新时间:2023-11-28 03:50:25 24 4
gpt4 key购买 nike

我正在 Microsoft Visual Studio 中使用 VB 创建自动化,就像应用程序一样项目路径为Visual Basic>windows classic Desktop>windows form应用程序(.NET框架)。代码是使用 VBA 编写的,它是一种形式,可以得到用户输入并将其粘贴到网络表单中,然后单击提交按钮并创建票证。我已经通过 VBA excel 运行此自动化。然而,由于某些情况,我需要将其创建为独立的应用程序。我在点击提交按钮时遇到问题。有人可以帮我把代码改正吗?

这是从 View 源中获取的 HTML 元素

    <input type="hidden" name="ticket_type" id="ticket_type" value="" />
<input type="hidden" name="quicklink_id" id="quicklink_id"value="0"/>
<textarea name="work_log" style="display:none"></textarea>
<textarea name="correspondence" style="display:none"></textarea>
<div id="action_bar" class="cti-search-enabled">
<div id="button_bar">
<a class="tt_button orange_button" href="#" onclick="ajax_submit()">
<span>Submit Ticket</span></a>
<a class="tt_button" href="#" onclick="build_quicklink()">
<span>Save as New Quicklink</span></a>

如您所见,有两个按钮,一个是“提交工单”和“另存为新的快速链接”。我需要单击“提交票证”按钮。前面在VBA中使用的代码是

    Call sel.executeScript("ajax_submit()", "javascript")

这是我在 .net 中的代码

     Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, 
ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs)
Handles WebBrowser1.DocumentCompleted

MessageBox.Show("Document loading completed!")
Me.WebBrowser1.Document.ExecCommand("ajax_submit()", "javascript")
End Sub

因此,一旦加载表单,它将显示一个消息框,然后单击提交按钮。但是这显示错误为

严重性代码描述项目文件行抑制状态错误 BC30455 未为“公共(public)重载 Sub ExecCommand(命令作为字符串,showUI 作为 bool 值,值作为对象)”的参数“值”指定参数。我的_第一

有人可以帮助我了解代码应该如何编写吗?抱歉,我是 .net(以及 VBA)的初学者

最佳答案

这似乎可以解决问题:

Me.WebBrowser1.Document.All("ID-Of-The-Button").InvokeMember‌​("Click")

关于javascript - 无法使用 .net 在网页中单击“提交”按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48035757/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com