如何点击网站上的按钮?

时间:2012-11-20 15:16:11

标签: vb.net vba

我正在尝试点击网站上的某个按钮。这是它的代码。

<div id="ff_submit_button">


<input type="image" onclick="javascript:return preFareFinderSubmitActions('The following information is needed to process your request:', 'Problem Pricing the Itinerary: Atlantic City Express Service offers adult fares only for all passengers.  Please modify your selection to continue. \n[Error ID: 1121S]')" src="/images/en/btn_ff_go.gif" alt="Click to Find Tickets" border="0" name="_handler=url.presentation.handler.request.rail.urlRailSearchRequestHandler/_xpath=/sessionWorkflow/productWorkflow[@product='Rail']">

</div>

目前,我点击“alt =”点击查找“使用此代码在一个按钮中的票证。”

    For Each webpageelement As HtmlElement In allelements

        If webpageelement.GetAttribute("alt") = "Click to Find Tickets" Then
            webpageelement.InvokeMember("click")

        End If

它有效,但问题是网站上还有另一个区域也使用了该alt。因此,它要求输入用户名和密码。我的代码行现在是一个按钮。

1 个答案:

答案 0 :(得分:0)

而不是alt,要检查的更好的元素是id - 这是meant to provide a unique identifier,尽管您需要将其添加到输入标记。

相关问题