惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
Cisco Blogs
Schneier on Security
Schneier on Security
T
Tor Project blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Tenable Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Threat Research - Cisco Blogs
C
CERT Recently Published Vulnerability Notes
Security Latest
Security Latest
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
NISL@THU
NISL@THU
L
Lohrmann on Cybersecurity
Scott Helme
Scott Helme
Webroot Blog
Webroot Blog
Project Zero
Project Zero
Google Online Security Blog
Google Online Security Blog
The Last Watchdog
The Last Watchdog
Spread Privacy
Spread Privacy
Hacker News: Ask HN
Hacker News: Ask HN
PCI Perspectives
PCI Perspectives
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
W
WeLiveSecurity
Attack and Defense Labs
Attack and Defense Labs
D
Darknet – Hacking Tools, Hacker News & Cyber Security
N
News | PayPal Newsroom
Help Net Security
Help Net Security
The Hacker News
The Hacker News
H
Heimdal Security Blog
O
OpenAI News
S
Security @ Cisco Blogs
N
News and Events Feed by Topic
Cyberwarzone
Cyberwarzone
Simon Willison's Weblog
Simon Willison's Weblog
G
GRAHAM CLULEY
www.infosecurity-magazine.com
www.infosecurity-magazine.com
博客园 - 叶小钗
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Hacker News - Newest:
Hacker News - Newest: "LLM"
T
Tailwind CSS Blog
大猫的无限游戏
大猫的无限游戏
A
Arctic Wolf
I
Intezer
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
S
Security Affairs
P
Proofpoint News Feed
S
Secure Thoughts
腾讯CDC
Google DeepMind News
Google DeepMind News
量子位
罗磊的独立博客

博客园 - flashicp

一个购物分享网站核心源码分析 ECSHOP读写分离配置与改造(转载) - flashicp 多年没有管理的技术博客了,即日起开始管理起技术博客 Apache里的 MPM 调优比较详细 zend framework多模块多布局配置 c# office不同版本下中使用Excel 目录下的文件 - flashicp - 博客园 中秋 国庆 最近在忙项目,好久不来 转 :如何提高自己的编程水平 衣物去污指南 转 洗衣小窍门集锦 牙膏的妙用 转 家居小窍门 (二) 转 家居小窍门 (一) 转 --有些事情需要注意 WinForm的App.config 保存我的操作日志 关于sql server表名 和字段的一点操作
c# WebBrowser网页操作-元素获取_事件操作
flashicp · 2012-05-27 · via 博客园 - flashicp

usingSystem; usingSystem.Collections.Generic; usingSystem.Linq; usingSystem.Text; usingSystem.Windows.Forms;// namespaceWebBrowser网页操作 { publicclassElement { //根据Name获取元素 publicHtmlElement GetElement_Name(WebBrowser wb,stringName) { HtmlElement e = wb.Document.All[Name]; returne; } //根据Id获取元素 publicHtmlElement GetElement_Id(WebBrowser wb, stringid) { HtmlElement e = wb.Document.GetElementById(id); returne; } //根据Index获取元素 publicHtmlElement GetElement_Index(WebBrowser wb,intindex) { HtmlElement e = wb.Document.All[index]; returne; } //获取form表单名name,返回表单 publicHtmlElement GetElement_Form(WebBrowser wb,stringform_name) { HtmlElement e = wb.Document.Forms[form_name]; returne; } //设置元素value属性的值 publicvoidWrite_value(HtmlElement e,stringvalue) { e.SetAttribute("value", value); } //执行元素的方法,如:click,submit(需Form表单名)等 publicvoidBtn_click(HtmlElement e,strings) { e.InvokeMember(s); } } } 这是调用这个类的窗体代码: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 usingSystem; usingSystem.Collections.Generic; usingSystem.ComponentModel; usingSystem.Data; usingSystem.Drawing; usingSystem.Linq; usingSystem.Text; usingSystem.Windows.Forms; namespaceWebBrowser网页操作 { publicpartialclassForm1 : Form { Element el = newElement(); publicForm1() { InitializeComponent(); } privatevoidForm1_Load(objectsender, EventArgs e) { webBrowser1.Navigate(Application.StartupPath + @"\Test.html"); } privatevoidbutton1_Click(objectsender, EventArgs e) { el.Write_value(el.GetElement_Name(webBrowser1,"username"),"isaced"); } privatevoidbutton2_Click(objectsender, EventArgs e) { el.Write_value(el.GetElement_Id(webBrowser1, "password"), "123456"); } privatevoidbutton3_Click(objectsender, EventArgs e) { el.Btn_click(el.GetElement_Id(webBrowser1,"button"),"click");//方法用的按钮click } privatevoidbutton4_Click(objectsender, EventArgs e) { el.Btn_click(el.GetElement_Form(webBrowser1, "form1"), "submit");//先获取表单,再调用表单的submit方法 } } }

posted on 2012-05-27 22:52  flashicp  阅读(4856)  评论()    收藏  举报