简体   繁体   中英

Unable to Click Submit button in webpage using .net

Im creating a automation using VB in microsoft Visual Studio like a app the project path is Visual Basic>windows classic Desktop>windows form app(.NET framework). Code is written using VBA and it is a form which gets user input and paste it into a webform and click a submit button and create a Ticket. I already have this automation running via VBA excel. however due to some circumstances i need to create it as a standalone app instead. I have problem in clicking the submit button. can someone please assist me in putting the code right.

this is the HTML element taken from view source

    <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>

as you can see there are two buttons, one is Submit Ticket and Save as New Quicklink. i need to click the Submit Ticket button. The earlier code is used in VBA is

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

This is my code in .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

so once the form is loaded, it will show a message box and then should click the submit button. however this is showing error as

Severity Code Description Project File Line Suppression State Error BC30455 Argument not specified for parameter 'value' of 'Public Overloads Sub ExecCommand(command As String, showUI As Boolean, value As Object)'. My_First

Can someone help me on how the code should be. Sorry im a beginner in .net (and VBA as well)

这似乎可以解决问题:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM