求IE自动化方案 N多软件可以搞定win runner,load runner,QTP 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 win runner,load runner,QTP 把网址和要执行的脚本写到一个文件里面,然后软件自动一步步,Navigate 然后算了,复制一段给你吧 void CMyDlg::OnDocumentCompleteExplorer1(LPDISPATCH pDisp, VARIANT FAR* URL) { // TODO: Add your control notification handler code here try{ if(CanGo&&list) { if (glpDisp && glpDisp == pDisp) { IHTMLWindow2 *pw=NULL; IHTMLDocument2 *ph=(IHTMLDocument2*)m_e.GetDocument(); ph->get_parentWindow(&pw); VARIANT ret; IHTMLElement* pe=NULL; ph->get_body(&pe); if(pe!=NULL) { BSTR bstr; pe->get_innerHTML(&bstr); CString str=bstr; if(e1==0) { if(str.Find("playerusername")!=-1) { e1++; switch(list->type) { case 1: //3 if(list->i.size()>0) { pw->execScript(CComBSTR("document.all.playerusername.value="+list->tel),CComBSTR("javascript"),&ret); pw->execScript(CComBSTR("document.all.replayerusername.value="+list->tel),CComBSTR("javascript"),&ret); pw->execScript(CComBSTR("document.all.BuyNumber.value="+list->i[0]),CComBSTR("javascript"),&ret); pw->execScript(CComBSTR("document.all.form.submit()"),CComBSTR("javascript"),&ret); } else { SetEvent(ev); } break; case 2: ................. load runner是三个推荐软件里最好的 最方便的自测效率最高 Load runner,可以实现你要的功能,我们的测试就用的这个 我的C#代码。用的WebBrowser控件。 HtmlDocument doc = wb.Document; if (doc != null) { doc.All["txtName"].SetAttribute("value", Helper.getname()); doc.All["txtCode"].SetAttribute("value", Card.GetID( Card.CreateID())); doc.Forms["fm1"].SetAttribute("target", "_top"); //doc.Forms["fm1"].ScrollIntoView(false); HTMLDocument html = (HTMLDocument)doc.DomDocument; IHTMLWindow2 win = html.parentWindow; string js = "document.all.Submit2.scrollIntoView(false);"; win.execScript(js, "javascript"); doc.All["codestr"].Focus(); //index++; } AUTOHOTKEY,非常小巧,也支持脚本语言,我们的C/S软件就用这个做的测试 const config_ = "config.ini" '配置文件名称const ForReading = 1const ForWriting = 2Dim fso,Ieo,Control_MarkSet fso = CreateObject("Scripting.FileSystemObject")'WScript.Echo ReadConfigRegExpConfig()Function ReadConfig() If (fso.FileExists(config_)) Then Set Readobj=fso.OpenTextFile(config_,ForReading) ReadConfig = Readobj.ReadAll Set readobj=Nothing Else WScript.Timeout = 10 WScript.Echo "为了正常启动在当前目录下需要配置文件(" & config_ & ")" WScript.Quit End IfEnd FunctionFunction RegExpConfig() 'ReadTextStream Set RegTmp1 = New RegExp RegTmp1.Global = True RegTmp1.IgnoreCase = True RegTmp1.Pattern = "P(\d{3})=(\S+)\s(\S+)\s(\S+)" Set RegSet = RegTmp1.Execute(ReadConfig()) For Each Match In RegSet Webbrowser Match.SubMatches(0),Match.SubMatches(1),Match.SubMatches(2),Match.SubMatches(3) 'WScript.Echo match.value 'Wscript.Echo Match.SubMatches(0) & Match.SubMatches(1) & Match.SubMatches(2) '根据子集数目列出数组 子集括号数-1 'For Each substr in match.submatches ' WScript.Echo substr 'Next '枚举 NextEnd FunctionFunction Webbrowser(Listnum_,Address_,UserName_,PassWord_) 'WScript.Echo "Address:" & Address_ & " UserName:" & UserName_ & " Password:" &PassWord_ Control_Mark = True Set Ieo = WScript.CreateObject("InternetExplorer.Application","Event_") Ieo.Navigate (Address_) While (Ieo.Busy) WScript.Sleep 200 Wend Ieo.Visible=1 '登陆行为 Ieo.Document.All.wd.Value=" UserName:" & UserName_ & " Password:" &PassWord_ Ieo.Document.All.sb.click '执行页面脚本行为 'Ieo.Document.parentWindow.ExecScript("fun_name();","javascript") '等待窗口关闭 While Control_Mark WScript.Sleep 200 Wend 'WScript.Echo Listnum_ & "已完成操作" End FunctionSub Event_OnQuit() Set Ieo = Nothing Control_Mark = False 'WScript.Echo 当前IE实例已释放"End Sub'''''''''''''''''''''''''config_示例''''''''[Server]'P001=www.baidu.com admin1 123456a'P002=www.baidu.com admin2 123456b'P003=www.baidu.com admin3 123456c'''''''''''''''''''''''''''''''''''''''''' 关于组播的一些问题,纯新手,希望讲的通俗一些. datagridview中实现树型结构! 新手求教。 窗口打开时背景图片闪烁 VS2005左边工具栏的控件都没了,急! C#写的ASP.NET集成采集系统开源项目 进程条的问题 有关公式如何计算 C# winform中如何使用.DB或.DBF 的文件数据库 在Web上怎么实现类似于163邮件中的附件获取,也就是怎么实现另存为菜单? C# 有error 帮帮忙 请高手帮忙下如何截断Float数据
{
// TODO: Add your control notification handler code here
try{
if(CanGo&&list)
{
if (glpDisp && glpDisp == pDisp)
{
IHTMLWindow2 *pw=NULL;
IHTMLDocument2 *ph=(IHTMLDocument2*)m_e.GetDocument();
ph->get_parentWindow(&pw);
VARIANT ret;
IHTMLElement* pe=NULL;
ph->get_body(&pe);
if(pe!=NULL)
{
BSTR bstr;
pe->get_innerHTML(&bstr);
CString str=bstr;
if(e1==0)
{
if(str.Find("playerusername")!=-1)
{
e1++;
switch(list->type)
{
case 1:
//3
if(list->i.size()>0)
{
pw->execScript(CComBSTR("document.all.playerusername.value="+list->tel),CComBSTR("javascript"),&ret);
pw->execScript(CComBSTR("document.all.replayerusername.value="+list->tel),CComBSTR("javascript"),&ret);
pw->execScript(CComBSTR("document.all.BuyNumber.value="+list->i[0]),CComBSTR("javascript"),&ret);
pw->execScript(CComBSTR("document.all.form.submit()"),CComBSTR("javascript"),&ret);
}
else
{
SetEvent(ev);
}
break;
case 2:
.................
if (doc != null)
{
doc.All["txtName"].SetAttribute("value", Helper.getname());
doc.All["txtCode"].SetAttribute("value", Card.GetID( Card.CreateID()));
doc.Forms["fm1"].SetAttribute("target", "_top");
//doc.Forms["fm1"].ScrollIntoView(false);
HTMLDocument html = (HTMLDocument)doc.DomDocument;
IHTMLWindow2 win = html.parentWindow;
string js = "document.all.Submit2.scrollIntoView(false);";
win.execScript(js, "javascript");
doc.All["codestr"].Focus();
//index++;
}
const ForReading = 1
const ForWriting = 2Dim fso,Ieo,Control_Mark
Set fso = CreateObject("Scripting.FileSystemObject")'WScript.Echo ReadConfig
RegExpConfig()Function ReadConfig()
If (fso.FileExists(config_)) Then
Set Readobj=fso.OpenTextFile(config_,ForReading)
ReadConfig = Readobj.ReadAll
Set readobj=Nothing
Else
WScript.Timeout = 10
WScript.Echo "为了正常启动在当前目录下需要配置文件(" & config_ & ")"
WScript.Quit
End If
End FunctionFunction RegExpConfig() 'ReadTextStream
Set RegTmp1 = New RegExp
RegTmp1.Global = True
RegTmp1.IgnoreCase = True
RegTmp1.Pattern = "P(\d{3})=(\S+)\s(\S+)\s(\S+)"
Set RegSet = RegTmp1.Execute(ReadConfig())
For Each Match In RegSet
Webbrowser Match.SubMatches(0),Match.SubMatches(1),Match.SubMatches(2),Match.SubMatches(3)
'WScript.Echo match.value
'Wscript.Echo Match.SubMatches(0) & Match.SubMatches(1) & Match.SubMatches(2)
'根据子集数目列出数组 子集括号数-1
'For Each substr in match.submatches
' WScript.Echo substr
'Next
'枚举
Next
End FunctionFunction Webbrowser(Listnum_,Address_,UserName_,PassWord_)
'WScript.Echo "Address:" & Address_ & " UserName:" & UserName_ & " Password:" &PassWord_
Control_Mark = True
Set Ieo = WScript.CreateObject("InternetExplorer.Application","Event_")
Ieo.Navigate (Address_)
While (Ieo.Busy)
WScript.Sleep 200
Wend
Ieo.Visible=1
'登陆行为
Ieo.Document.All.wd.Value=" UserName:" & UserName_ & " Password:" &PassWord_
Ieo.Document.All.sb.click
'执行页面脚本行为
'Ieo.Document.parentWindow.ExecScript("fun_name();","javascript")
'等待窗口关闭
While Control_Mark
WScript.Sleep 200
Wend
'WScript.Echo Listnum_ & "已完成操作"
End FunctionSub Event_OnQuit()
Set Ieo = Nothing
Control_Mark = False
'WScript.Echo 当前IE实例已释放"
End Sub'''''''''''''''''''''''''config_示例'''''''
'[Server]
'P001=www.baidu.com admin1 123456a
'P002=www.baidu.com admin2 123456b
'P003=www.baidu.com admin3 123456c
''''''''''''''''''''''''''''''''''''''''''