webBrowser下拉表选项抢焦点问题请教 本帖最后由 u011321421 于 2013-11-15 12:57:24 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以输入啊,而且根本不需要定位焦点啊。 if (WB1.Document.GetElementById("password") != null) { WB1.Document.GetElementById("nick").SetAttribute("value", "aaabbbccc");// WB1.Document.GetElementById("nick").Focus(); WB1.Document.GetElementById("password").SetAttribute("value", "xxxxxxxxxx");// WB1.Document.GetElementById("password").Focus(); WB1.Document.GetElementById("password_again").SetAttribute("value", "xxxxxxxxxxx");// WB1.Document.GetElementById("password_again").Focus(); this.WB1.Document.GetElementById("year_11").InvokeMember("Click"); this.WB1.Document.GetElementById("month_5").InvokeMember("Click"); this.WB1.Document.GetElementById("day_6").InvokeMember("Click"); if (WB1.Document.GetElementById("code") != null) {// WB1.Document.GetElementById("code").Focus(); WB1.Document.GetElementById("code").SetAttribute("value", "aaaaaaaaaaaaa"); } } 不处理焦点你确定能注册成功??这一句:webQQReq.Document.GetElementById("nick").Focus();注释了的话,点击注册时会提示【昵称不能为空】而且无法在webbrowser控件中的文本框输入验证码,只能通过winform上控件的文本框赋值。通过抓包发现了,“抢焦点”是激发了某个事件导致不断地向服务器请求数据: 你提的问题是抢焦点无法输入验证码,我给的代码已经可以输入验证码了,只是还无法完成注册的问题;不过你已经找到部分原因了,昵称和密码那里要setfocus()才不会提示为空;最重要的是年月日那里会不断的跳,我想原因是它可能要判断 是否闰年、某月多少天之类的逻辑,当然也要用setfocus,但是不能连续点击,要给它一定的响应时间,加上Application.DoEvents();就可以了。 if (WB1.Document.GetElementById("password") != null) { WB1.Document.GetElementById("nick").SetAttribute("value", "aaabbbccc"); WB1.Document.GetElementById("nick").Focus(); WB1.Document.GetElementById("password").SetAttribute("value", "xxx123"); WB1.Document.GetElementById("password").Focus(); WB1.Document.GetElementById("password_again").SetAttribute("value", "xxx123"); WB1.Document.GetElementById("password_again").Focus(); this.WB1.Document.GetElementById("year_11").InvokeMember("Click"); this.WB1.Document.GetElementById("year_11").Focus(); Application.DoEvents(); this.WB1.Document.GetElementById("month_5").InvokeMember("Click"); this.WB1.Document.GetElementById("month_5").Focus(); Application.DoEvents(); this.WB1.Document.GetElementById("day_6").InvokeMember("Click"); this.WB1.Document.GetElementById("day_6").Focus(); Application.DoEvents(); if (WB1.Document.GetElementById("code") != null) { WB1.Document.GetElementById("code").Focus(); WB1.Document.GetElementById("code").SetAttribute("value", txtcode.Text); } } WB1.Document.GetElementById("submit").InvokeMember("Click");上面的代码经过亲测,一次通过注册,直接就调到输入手机号那里了! winfrom 异步委托出现的线程问题~ 如何获取?? DataGridView显示问题 一个小问题,都进来答答吧 怎样打印瘦体字 新手问个写字符串到文本的问题。 有没有什么方法加载自己目录里面的字体文件 Dropdownlist的回传问题 水晶报表的数据为何刷新不了? 高手们过来帮小弟解决一下 textbox内容如何与dgv一起打印出来? c#编写个人理财系统
{
WB1.Document.GetElementById("nick").SetAttribute("value", "aaabbbccc");
// WB1.Document.GetElementById("nick").Focus(); WB1.Document.GetElementById("password").SetAttribute("value", "xxxxxxxxxx");
// WB1.Document.GetElementById("password").Focus(); WB1.Document.GetElementById("password_again").SetAttribute("value", "xxxxxxxxxxx");
// WB1.Document.GetElementById("password_again").Focus(); this.WB1.Document.GetElementById("year_11").InvokeMember("Click");
this.WB1.Document.GetElementById("month_5").InvokeMember("Click");
this.WB1.Document.GetElementById("day_6").InvokeMember("Click"); if (WB1.Document.GetElementById("code") != null)
{
// WB1.Document.GetElementById("code").Focus();
WB1.Document.GetElementById("code").SetAttribute("value", "aaaaaaaaaaaaa");
} }
不处理焦点你确定能注册成功??
这一句:webQQReq.Document.GetElementById("nick").Focus();
注释了的话,点击注册时会提示【昵称不能为空】
而且无法在webbrowser控件中的文本框输入验证码,只能通过winform上控件的文本框赋值。通过抓包发现了,“抢焦点”是激发了某个事件导致不断地向服务器请求数据:
不过你已经找到部分原因了,昵称和密码那里要setfocus()才不会提示为空;
最重要的是年月日那里会不断的跳,我想原因是它可能要判断 是否闰年、某月多少天之类的逻辑,当然也要用setfocus,但是不能连续点击,要给它一定的响应时间,加上Application.DoEvents();就可以了。 if (WB1.Document.GetElementById("password") != null)
{
WB1.Document.GetElementById("nick").SetAttribute("value", "aaabbbccc");
WB1.Document.GetElementById("nick").Focus(); WB1.Document.GetElementById("password").SetAttribute("value", "xxx123");
WB1.Document.GetElementById("password").Focus(); WB1.Document.GetElementById("password_again").SetAttribute("value", "xxx123");
WB1.Document.GetElementById("password_again").Focus(); this.WB1.Document.GetElementById("year_11").InvokeMember("Click");
this.WB1.Document.GetElementById("year_11").Focus();
Application.DoEvents();
this.WB1.Document.GetElementById("month_5").InvokeMember("Click");
this.WB1.Document.GetElementById("month_5").Focus();
Application.DoEvents();
this.WB1.Document.GetElementById("day_6").InvokeMember("Click");
this.WB1.Document.GetElementById("day_6").Focus();
Application.DoEvents(); if (WB1.Document.GetElementById("code") != null)
{
WB1.Document.GetElementById("code").Focus();
WB1.Document.GetElementById("code").SetAttribute("value", txtcode.Text);
} }
WB1.Document.GetElementById("submit").InvokeMember("Click");上面的代码经过亲测,一次通过注册,直接就调到输入手机号那里了!