如何从webbrowser选择javascript代码下拉选项

时间:2014-07-27 22:47:37

标签: c# webbrowser-control

我写了一个用于进行热门电话验证的代码。但是当我点击时,所有字段都被填满,但是显示“消息”。我该如何处理这段代码?

       <div id="iPhoneSection" style="display: none">
                <div class="InputRow">
                    <label id="iSmsHeading" for="DisplayPhoneCountryISO" class="Label" style="display: none"></label>
                    <div class="bottompad">
                        <select id="DisplayPhoneCountryISO" name="DisplayPhoneCountryISO" aria-labelledby="iSmsHeading"></select>
                    </div>
                    <div id="PhoneError" class="ErrMsg prooferror" style="display: none" aria-live="assertive" aria-relevant="text" aria-atomic="true"></div>
                    <div id="PhoneContainer" class="phcontainer"></div>
                </div>
                <div class="toppad">
                    Verify phone via:
                    <input id="idSMSChannel" type="radio" name="nameMNCChannel" value="SMS" class="inlineRadio" checked />
                    <label for="idSMSChannel">Text</label>
                    <input id="idVoiceChannel" type="radio" name="nameMNCChannel" value="Voice" class="inlineRadio" />
                    <label for="idVoiceChannel">Call</label>
                </div>
            </div>

请检查以下代码:

     webBrowser1.Document.GetElementById("DisplayPhoneCountryISO").SetAttribute("value", "BD");

        webBrowser1.Document.GetElementById("DisplayPhoneNumber").SetAttribute("value", mobile.Text);



        HtmlElementCollection elc = this.webBrowser1.Document.GetElementsByTagName("input");
        foreach (HtmlElement el in elc)
        {
            if (el.GetAttribute("type").Equals("submit"))
            {
                el.InvokeMember("Click");
            }
        }

0 个答案:

没有答案