zoukankan      html  css  js  c++  java
  • 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时)遍历窗体元素
  • 相关阅读:
    《构建之法》
    《构建之法》第一单元
    查询特殊字符
    Excel文件批量导入SQLSERVER数据库中(利用Foreach容器)
    当月的最后一天SELECT DATEADD(dd,1,DATEADD(mm, DATEDIFF(m,0,getdate())+1, 0)) 20140930 00:00:00.000
    the difference between primary key and unique key
    sql中如何再判断一个字段是否为空,如果不为空然后再Select这个字段,这要如何写呢?
    union和union all的区别
    UIImageView的基本使用
    UINavigationController导航控制器
  • 原文地址:https://www.cnblogs.com/goody9807/p/2470588.html
Copyright © 2011-2022 走看看