使用VBAlogin到网站并清除以前的login凭证

我目前使用这个填充用户名和密码在网页使用VBA代码login到一个网站,但我遇到了一个问题。 由于用户名和密码已经保存在浏览器中,因此会再次添加uid / pass并在login过程中创build错误。 有没有办法可以添加一些代码来清除任何以前input的uid / pass?

Sub test() ' open IE, navigate to the desired page and loop until fully loaded Set ie = CreateObject("InternetExplorer.Application") my_url = "https://hb2.bankleumi.co.il/e/Login.html" With ie .Visible = True .Navigate my_url .Top = 50 .Left = 530 .Height = 400 .Width = 400 Do Until Not ie.Busy And ie.readyState = 4 DoEvents Loop End With ' Input the userid and password ie.Document.getElementById("uid").Value = "testID" ie.Document.getElementById("password").Value = "testPW" ' Click the "Search" button ie.Document.getElementById("enter").Click Do Until Not ie.Busy And ie.readyState = 4 DoEvents Loop End Sub 

您可以testing当前加载的用户名是否相同,如果是,只需单击,否则,用.Value = ""清除现有的用户名

 If ie.Document.getElementById("uid").Value = "testID" Then Else ie.Document.getElementById("uid").Value = "" ie.Document.getElementById("password").Value = "" ie.Document.getElementById("uid").Value = "testID" ie.Document.getElementById("password").Value = "testPW" End If