C#如何在webBrowser1控件通過TagName,Name查找元素(沒有ID時)遍歷窗體元素


C#如何在webBrowser1控件通過TagName,Name查
// 防止頁面多次刷新頁面執行
             if (num ==  1)
            {
                 string GetUserName = System.Configuration.ConfigurationSettings.AppSettings[ " Y2000UserName "].ToString();
                 string GetUserPassword = System.Configuration.ConfigurationSettings.AppSettings[ " Y2000UserPassword "].ToString();
                 int a =  1;
                 int all = webBrowse東四飯店薩芬r1.Document.Body.All.Count;
                 for ( int i =  0; i < all; i++)
                {
                    HtmlElement GetElement = webBrowser1.Document.All[i];
                     // 取到包含input標簽的元素
                     if (GetElement.TagName.ToUpper().ToString() ==  " INPUT ")
                    {
                         // 根據input的Name屬性,找到該元素並賦值:給用戶名輸入框賦值
                         if (GetElement.Name.ToString() ==  " UserName ")
                        {
                            webBrowser1.Document.All[i].SetAttribute( " value ", GetUserName);
                        }
                       士大夫撒 上大夫大沙發  // 根據input的Name屬性,找到該元素並賦值:給密碼輸入框賦值
                         if (GetElement.Name.ToString() ==  " Passwd ")
                        {
                            webBrowser1.Document.All[i].SetAttribute( " value ", GetUserPassword);
                        }1
                     // 根據input的Name屬性,找到提交按鈕並執行動作
                     if (GetElement.Name.ToString() ==  " Submit ")
                    {222222
                         // 過濾點擊頁面中相同"name=Submit"的元素
                         if (a ==  1)
                        {
                            webBrowser1.Document.All[i].InvokeMember( " click ");
                        }
                        a++;
                    }
                }
                num++;
            }
元素(沒有ID時)遍歷窗體元素


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM