こんにちは、VB.NET を使用して Web サイトのボタンをクリックしようとしています。
.AHK で使用するコマンドは
Pwb.document.getElementsByTagName("IMG")[7].click
ボタン/Img HTML は以下のとおりです。
<img width="34" height="34" style="cursor: pointer;" onclick="doSubmit()" alt="" src="../../images/SC5Login07.jpg" border="0" complete="complete"/>
クリックすると、JavaScriptが実行されていることに気付きました。それが下です
function doSubmit() {
//Submit the form
if (document.getElementById("txtDBName").value == "") {
//Login security modifications - End
alert('You must select a Database');
}
else {
if (document.getElementById("txtUserName").value == "") {
alert('Please enter your Tesseract user id and password');
}
else {
//Set txtformEvent
document.getElementById("txtFormEvent").value = "onSubmit";
//Submit the form
document.getElementById("frmLoginLaunch").submit();
}
}
}
今、私は GetElementById があることを認識していますが、ID がないためにそれを機能させることができません。AHK と同じくらい簡単だと思っていましたが、そうではないようです。
基本的に、この dosubmit() 関数を呼び出す方法や、画像のクリックをシミュレートする方法はありますか?
誰かが助けてくれることを願っていますありがとう
ありがとう、これが私のログインコードです
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
WebBrowser1.Navigate("http://caan/SC5/SC_Login/aspx/login_launch.aspx?SOURCE=ESOLBRANCHLIVE")
While WebBrowser1.ReadyState <> WebBrowserReadyState.Complete
Application.DoEvents()
End While
WebBrowser1.Document.GetElementById("txtUserName").SetAttribute("value", "kieranw")
WebBrowser1.Document.GetElementById("txtPassword").SetAttribute("value", "kieranw")
Dim allImgTags As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("img")
If allImgTags IsNot Nothing Then
For Each img As HtmlElement In allImgTags
If img.GetAttribute("src").Contains("/images/SC5Login07.jpg") Then
img.InvokeMember("Click")
Exit For
End If
Next img
End If
End Sub
クラス終了