我就是作自动测试软件的.但是东西是公司的 :)在www.codeproject.com上面有一个简单的,大约能符合你的要求,好像是一个清华的(或者北大)的什么人写的.自己找找看.
解决方案 »
- C#操纵Excel数据导入导出问题
- checkedlistbox的问题
- DataGridView绑定datatable,改变datatable如何更行DataGridView
- 一个方法的参数问题
- 怎样得到应用程序所在文件夹的名称?
- 100分求:Cell组件有SaveToBuffer函数VB调用实例,怎样在C#中调用
- 如何正确配置ibitisnet框架。讲重点详细点 在线等
- 如何在C#编程中以特定身份登录访问网络邻居中的一个共享目录?
- 求C#分词组件,,,做网站上的搜索引擎用的
- Excel导入到Access中 Excel和access表的字段不一样怎么处理?
- sql问题
- 序列化和反序列化有什么作用!
英文的好难找,我没有找到,帮我找一下吧.
谢谢!!!
分数要多少我再加!
能讲一下大致的编程思路吗?
我试了一种方法可是不太顺利,我的方法是这样的:
1.Aximp c:\winnt\system32\shdocvw.dll
运行上述命令,产生“SHDocVw.dll”和“AxSHDocVw.dll”二个文件
2.将AxSHDocVw.dll引用到C#项目中.
3.AxSHDocVw.AxWebBrowser axWebBrowser1
生成一个流览器.
我目前进行到这一步,可以弹出一个自己的流览器,
我想抓住流览器中的组件(例如:input,select等),可是没办法抓到,
如果能够抓到这些组件,就能够得到他们的值,并记录下来,可能就能够实现了,
我不知道这样的思路是否正确.希望你能够指点一下.
{
///
/// Summary description for Form1.
///
///
[Serializable]
public class Form1 : System.Windows.Forms.Form ,IDocHostUIHandler
{
private AxSHDocVw.AxWebBrowser WebBrowser;
private System.Windows.Forms.Button button1;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();//
// TODO: Add any constructor code after InitializeComponent call
//
this.WebBrowser.DocumentComplete += new DWebBrowserEvents2_DocumentCompleteEventHandler(this.WebBrowser_DocumentComplete);
object flags = 0;
object targetFrame = String.Empty;
object postData = String.Empty;
object headers = String.Empty;
this.WebBrowser.Navigate("about:blank", ref flags, ref targetFrame, ref postData, ref headers);ICustomDoc cDoc = (ICustomDoc)this.WebBrowser.Document;
cDoc.SetUIHandler((IDocHostUIHandler)this);this.WebBrowser.Navigate(@"XXXX.htm", ref flags, ref targetFrame, ref postData, ref headers);
}///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.WebBrowser = new AxSHDocVw.AxWebBrowser();
this.button1 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.WebBrowser)).BeginInit();
this.SuspendLayout();
//
// WebBrowser
//
this.WebBrowser.Enabled = true;
this.WebBrowser.Location = new System.Drawing.Point(72, 32);
this.WebBrowser.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("WebBrowser.OcxState")));
this.WebBrowser.Size = new System.Drawing.Size(300, 150);
this.WebBrowser.TabIndex = 0;
//
// button1
//
this.button1.Location = new System.Drawing.Point(232, 152);
this.button1.Name = "button1";
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(384, 197);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.button1,
this.WebBrowser});
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.WebBrowser)).EndInit();
this.ResumeLayout(false);}
#endregion///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void WebBrowser_DocumentComplete(object sender, AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)
{
IHTMLDocument2 doc = (IHTMLDocument2)this.WebBrowser.Document;
HTMLButtonElement button = (HTMLButtonElement)doc.all.item("theButton", null);
HTMLButtonElement button1 = (HTMLButtonElement)doc.all.item("theButton1", null);
HTMLButtonElement button2 = (HTMLButtonElement)doc.all.item("theButton2", null);
((HTMLButtonElementEvents2_Event)button).onclick += new HTMLButtonElementEvents2_onclickEventHandler(this.Button_onclick);
((HTMLButtonElementEvents2_Event)button1).onclick += new HTMLButtonElementEvents2_onclickEventHandler(this.Button1_onclick);
((HTMLButtonElementEvents2_Event)button2).onclick += new HTMLButtonElementEvents2_onclickEventHandler(this.Button2_onclick);
}private bool Button_onclick(IHTMLEventObj e)
{
MessageBox.Show("Alert from the app: Received theButton.onclick!");
return true;
}
private bool Button1_onclick(IHTMLEventObj e)
{
MessageBox.Show("Alert from the app: Received theButton1.onclick!");
return true;
}
private bool Button2_onclick(IHTMLEventObj e)
{
MessageBox.Show("Alert from the app: Received theButton2.onclick!");
return true;
}// IDocHostUIHandler implementationvoid IDocHostUIHandler.EnableModeless(int fEnable)
{}void IDocHostUIHandler.FilterDataObject(MsHtmHstInterop.IDataObject pDO, out MsHtmHstInterop.IDataObject ppDORet)
{
ppDORet = null;
}void IDocHostUIHandler.GetDropTarget(IDropTarget pDropTarget, out IDropTarget ppDropTarget)
{
ppDropTarget = null;
}void IDocHostUIHandler.GetExternal(out object ppDispatch)
{
ppDispatch = null;
}void IDocHostUIHandler.GetHostInfo(ref _DOCHOSTUIINFO pInfo)
{}void IDocHostUIHandler.GetOptionKeyPath(out string pchKey, uint dw)
{
pchKey = null;
}void IDocHostUIHandler.HideUI()
{}void IDocHostUIHandler.OnDocWindowActivate(int fActivate)
{}void IDocHostUIHandler.OnFrameWindowActivate(int fActivate)
{}void IDocHostUIHandler.ResizeBorder(ref MsHtmHstInterop.tagRECT prcBorder, IOleInPlaceUIWindow pUIWindow, int fRameWindow)
{}void IDocHostUIHandler.ShowContextMenu(uint dwID, ref MsHtmHstInterop.tagPOINT ppt, object pcmdtReserved, object pdispReserved)
{}void IDocHostUIHandler.ShowUI(uint dwID, IOleInPlaceActiveObject pActiveObject, IOleCommandTarget pCommandTarget, IOleInPlaceFrame pFrame, IOleInPlaceUIWindow pDoc)
{}void IDocHostUIHandler.TranslateAccelerator(ref tagMSG lpmsg, ref Guid pguidCmdGroup, uint nCmdID)
{}void IDocHostUIHandler.TranslateUrl(uint dwTranslate, ref ushort pchURLIn, IntPtr ppchURLOut)
{}void IDocHostUIHandler.UpdateUI()
{}
private void Form1_Load(object sender, System.EventArgs e)
{}private void button1_Click(object sender, System.EventArgs e)
{}
}
}