2016-09-16 53 views
-1

我导航到使用网页:如何点击“登录”按钮导航到Internet Explorer对象的网页?

Dim IE As Object = CreateObject("InternetExplorer.Application") 
IE.Navigate("http://www.mypage.com") 
IE.Document.GetElementById("login").SetAttribute("Value", "myusername") 
IE.Document.GetElementById("password").SetAttribute("Value", "mypassword") 

'I can't get the submit button to work here. 

'the button is coded in html like this: 
<button class="btn btn-default pull-right" onclick="return checkCookies();" type="submit" value="Login">Login</button> 

我无法点击该按钮。任何帮助,将不胜感激。谢谢

+0

1-你到目前为止失败了什么? 2 - 这个代码片段应该由一个假设的例子吗?由于google.com没有登录页面,并且谷歌的实际登录页面的用户名和密码的元素标识是Email/Passwd,而不是登录名/密码... – soohoonigan

+0

@soohoonigan这是一个示例网页... ..... DUH! *我改变了网页。 – JustAnotherPersonYouDontKnow

+0

谁知道,我不得不登录谷歌与一个cefsharp项目... – soohoonigan

回答

0
Dim btns 
Set btns = IE.Document.GetElementsByClassName("btn btn-default pull-right") 
For Each btn In btns 
    If Button.InnerHTML.Contains("Login") Then 
     btn.Click 
     Exit For 
    End If 
Next 
+0

我没有使用webbrowser。 – JustAnotherPersonYouDontKnow