zoukankan      html  css  js  c++  java
  • IEBrowse学习笔记

     //登录
            private void toolStripButton1_Click(object sender, EventArgs e)
            {
               
                //ie.ExecuteScript("alert('ok!');");
            }
            //安装脚本
            private void toolStripButton2_Click(object sender, EventArgs e)
            {
               
                //ie.InstallScript("function add(num1,num2){return num1+num2;}");
                //ie.ExecuteScript("alert(add(1,2));");
            }
            //调用js
            private void toolStripButton3_Click(object sender, EventArgs e)
            {
               
                //ie.InstallScript("function showInfo(name,age){document.write('姓名:'+name+'年龄:'+age.toString());}");
                //ie.InvokeScript("showInfo",new object[]{"小红",10});
            }
            //JQuery模拟搜索百度
            private void toolStripButton4_Click(object sender, EventArgs e)
            {
            //    if (string.IsNullOrEmpty(this.txtKeyword.Text))
            //        return;
               
            //    ie.Navigate("http://www.baidu.com/");
            //    //等待页面载入后,才执行
            //    ie.IEFlow.Wait(new UrlCondition("wait","http://www.baidu.com/",StringCompareMode.StartWith));
            //    ie.InstallJQuery(JQuery.CodeMin);
            //    ie.ExecuteJQuery(JQuery.Create("'#kw'").Val("'"+ this.txtKeyword.Text.Trim()+"'"));
            //    ie.ExecuteJQuery(JQuery.Create("'#su'").Click());
            }
    
            private void btnStraRe_Click(object sender, EventArgs e)
            {
            //    this.ie.IERecord.InstallRecord();
            //    this.ie.IERecord.BeginRecord();
            }
    
            private void btnEndRe_Click(object sender, EventArgs e)
            {
                //this.ie.IERecord.EndRecord();
            }
    
            private void btnRe_Click(object sender, EventArgs e)
            {
                //this.ie.IERecord.BeginReplay();
            }
    
            private void btnSave_Click(object sender, EventArgs e)
            {
                //this.ie.IERecord.SaveAction(@"record.txt");
            }
    
            private void btnLoad_Click(object sender, EventArgs e)
            {
                //this.ie.IERecord.LoadAction(@"record.txt");
            }
    

      自动登录 干部在线培训

    private void btnLogin_Click(object sender, EventArgs e)
            {
                //ie.IEFlow.Wait(new UrlCondition("wait", "http://passport.chinahrt.com/login.do", StringCompareMode.StartWith));
                //ie.InstallJQuery(JQuery.CodeMin);
                //ie.ExecuteJQuery(JQuery.Create("'#loginName'").Val("'" + this.txtName.Text.Trim() + "'"));
                //ie.ExecuteJQuery(JQuery.Create("'#loginPwd'").Val("'" + this.txtPwd.Text.Trim() + "'").toMD5());
                //ie.ExecuteJQuery(JQuery.Create("'#loginBtn'").Click());
                //以上采用JQuery方法,不能实现toMD5方法。解放方法1:实现toMD5方法;方法2:调本原来的checkSubmit();方法3:用webBrowser给文本框赋值,再调用checkSubmit方法
                //只能用方法3了。因为用ie,给loginPwd赋值后,再执行submit,变量没有变成MD5.
                HtmlElement name = wbBrowser.Document.All["loginName"];
                HtmlElement pwd = wbBrowser.Document.All["loginPwd"];
                HtmlElement sub = wbBrowser.Document.All["loginBtn"];
    
                name.SetAttribute("value",this.txtName.Text.Trim());
                pwd.SetAttribute("value", this.txtPwd.Text.Trim());
                sub.InvokeMember("click");
    
    
            }
    

      

  • 相关阅读:
    优酷土豆的Redis服务平台化之路
    [C#]使用Gembox.SpreadSheet向Excel写入数据及图表
    [C#]使用Join与GroupJoin将两个集合进行关联与分组
    [C#]使用TcpListener及TcpClient开发一个简单的Chat工具
    超棒黑客必备清单
    [C#]使用dnSpy对目标程序(EXE或DLL)进行反编译修改并编译运行
    [C#源代码]使用SCPI指令对通信端口(RS232/USB/GPIB/LAN)进行仪器编程
    [C#]使用Costura.Fody将源DLL合并到目标EXE
    [C#]使用ILMerge将源DLL合并到目标EXE(.NET4.6.2)
    详解C#7.0新特性
  • 原文地址:https://www.cnblogs.com/hbjohnsan/p/3216411.html
Copyright © 2011-2022 走看看