如何使用VB单击网页中的按钮? [英] How to click a button in web page using VB?

查看:205
本文介绍了如何使用VB单击网页中的按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个VB脚本,点击网页上的按钮。我见过这样的答案,比如这个<他们在哪里提交表格。我不想要这个,因为我需要用脚本点击按钮,以便点击按钮的通常工作流程。

I'm creating a VB script that clicks a button on a webpage. I've seen answers such as this where they submit the form. I don't want this since I require to click on the button with a script so that the usual workflow of clicking a button is engaged.

顺便说一句,我是使用GWT和SmartClient,这使得ID变得更加复杂,因为它被混淆了。为了解决这个问题,我使用了GWT DEBUG_ID_PREFIX

By the way I'm using GWT and SmartClient which makes it a bit more complex as ID's get obfuscated. To overcome this I'm using GWT DEBUG_ID_PREFIX

推荐答案

如果你给了一个GWT按钮样本来获得帮助,对于那些不熟悉像我这样的GWT的人。

Would be nice if you gave a sample of a GWT button to getting help from for those who does not familiar with GWT like me. I found a page that contains a GWT button (hope) and wrote something based on that.
Consider the following code.

Sub WaitUntil(varObj)
    On Error Resume Next
    Do
        WScript.Sleep 100
    Loop Until Not varObj Is Nothing
    WScript.Sleep 500
End Sub

Dim IE
Set IE = CreateObject("InternetExplorer.Application")
    IE.Visible = True
    IE.Navigate "http://gwt.google.com/samples/Showcase/Showcase.html#!CwBasicButton"
    WScript.Sleep 500
    WaitUntil IE.Document 'wait until the document is ready
    WaitUntil IE.Document.getElementById("gwt-debug-cwBasicButton-normal") 'wait until the button is initialized
    Dim theButton
    Set theButton = IE.Document.getElementById("gwt-debug-cwBasicButton-normal")
        theButton.Click
        'theButton.fireEvent "onclick" 'another way
Set IE = Nothing

这篇关于如何使用VB单击网页中的按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆