admin管理员组文章数量:1402913
A website shows a table based options to choose. HTML
is
<td width="33%" class="cont"><input type="radio" name="gatewayIDV" onclick="setBank(11,0,1)">
<td width="33%" class="cont"><input type="radio" name="gatewayIDV" onclick="setBank(3,0,1)">
I want to Invoke click of radio of string "setBank(11,0,1)". How do I? all radio name are same but onclick()
parameter is different.
in JavaScript someone does this some code are here but how I do this in c#
I try this but never work:
if (webBrowser1.DocumentText.IndexOf("setBank(11,0,1)", StringComparison.InvariantCultureIgnoreCase) > 1)
{
webBrowser1.Document.GetElementById("gatewayIDV").InvokeMember("click");
}
JavaScript:
$("td.cont").each(function(index) {
var $this = $(this);
var gonext = true;
if($this.html().search(searchStr) != -1) {
$(document).BookingEngine("setAutomationRunningStatus",
!tabData.automationRunning);
console.log(index+":"+$this.html()+":");
$this.children("input[name='gatewayIDV']").click();
gonext = false;
}
return gonext;
});
A website shows a table based options to choose. HTML
is
<td width="33%" class="cont"><input type="radio" name="gatewayIDV" onclick="setBank(11,0,1)">
<td width="33%" class="cont"><input type="radio" name="gatewayIDV" onclick="setBank(3,0,1)">
I want to Invoke click of radio of string "setBank(11,0,1)". How do I? all radio name are same but onclick()
parameter is different.
in JavaScript someone does this some code are here but how I do this in c#
I try this but never work:
if (webBrowser1.DocumentText.IndexOf("setBank(11,0,1)", StringComparison.InvariantCultureIgnoreCase) > 1)
{
webBrowser1.Document.GetElementById("gatewayIDV").InvokeMember("click");
}
JavaScript:
$("td.cont").each(function(index) {
var $this = $(this);
var gonext = true;
if($this.html().search(searchStr) != -1) {
$(document).BookingEngine("setAutomationRunningStatus",
!tabData.automationRunning);
console.log(index+":"+$this.html()+":");
$this.children("input[name='gatewayIDV']").click();
gonext = false;
}
return gonext;
});
Share
Improve this question
edited Feb 14, 2017 at 10:24
user7561749
asked Apr 11, 2013 at 17:05
BraheenBraheen
291 gold badge1 silver badge8 bronze badges
2
- can you give me url of target for test result? – KF2 Commented Apr 11, 2013 at 17:20
- website login require. how i contact u and give details – Braheen Commented Apr 11, 2013 at 17:33
1 Answer
Reset to default 3You have multi radio button input you must loop through them,try this:
private void Form1_Load_1(object sender, EventArgs e)
{
webBrowser1.Navigate("url");
}
private void webBrowser1_DocumentCompleted_1(object sender, WebBrowserDocumentCompletedEventArgs e)
{
foreach (HtmlElement el in webBrowser1.Document.GetElementsByTagName("input"))
{
if (el.Name == "gatewayIDV")
{
el.InvokeMember("Click");
}
}
}
Edited
For specific radio button
private void Form1_Load_1(object sender, EventArgs e)
{
webBrowser1.Navigate(@"E:\Documents and Settings\Ali\Desktop\ww.html");
}
private void webBrowser1_DocumentCompleted_1(object sender, WebBrowserDocumentCompletedEventArgs e)
{
foreach (HtmlElement el in webBrowser1.Document.GetElementsByTagName("input"))
{
if (el.Name == "gatewayIDV" && el.OuterHtml.Contains("setBank(11,0,1)"))
{
el.InvokeMember("Click");
}
}
}
本文标签: cInvokeMember(quotclickquot) in WebBrowser controlStack Overflow
版权声明:本文标题:c# - InvokeMember("click") in WebBrowser control - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744327624a2600804.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论