2014-09-01 98 views
-1

有人可以帮助我。 我需要知道如何使用网页浏览器自动化表单,并点击包含“报告”文本的按钮。 我不能用ID来做,因为它们都有“发送”ID。C#点击具有相同编号的html按钮

this.form.target=''; 
     this.form.action='/foglioorario.php'; 
     this.form.submit();"><OPTION value='0'></OPTION><OPTION value='1'>Tirana</OPTION></SELECT></td> 
       </tr><tr> 
        <td><input name='azione' value='Importa Curva' type='button' class='TbStyle' onclick="on_click('form1', 'importForecast.php', 'import')"/></td> 
        <td colspan='2'><span style='margin-right:20px'> 
         Alpha:<input name='alpha' id='alpha' type='TEXT' maxlength='3' value='95' style='width:25px'/>% 
         </span> 
         <span style='margin-right:20px'> 
         TMS:<input name='tms' id='tms' type='TEXT' maxlength='3' value='290' style='width:25px'/> 
         </span>     
         <span>     
         <input type='submit' id='send' name='send' value='Compara curva' class='TbStyle'/> 
         </span> 
         <span> 
         <input type='submit' id='send' name='send' value='Export CC' class='TbStyle' title='Click per export Excel'/> 
         </span> 
        </td> 
        <td><input type='submit' id='send' name='send' value='Report' class='TbStyle'/> 
        <input type='submit' id='send' name='send' value='Export R' class='TbStyle' title='Click per export Excel'/></td> 
        <td><input type='submit' id='send' name='send' value='Riepilogo Sett' class='TbStyle'/> 
        <input type='submit' id='send' name='send' value='Export S' class='TbStyle' title='Click per export Excel'/></td> 
        <td> 
         <span>Pause: <input type='checkbox' name='chkpause' /></span> 
         <span style='padding-left:10px'>Disp.Strao: <input type='checkbox' name='chkStrao' /></span> 

       </tr> 
+0

存在的JavaScript和HTML在你的样品奇数组合你能请解释这是什么? – Dalorzo 2014-09-01 19:17:56

回答

1

我想我明白你的意思,让我知道这是否适合你。

IHTMLElementCollection buttonCol = doc.getElementsByTagName("input"); 
foreach (IHTMLElement btn in buttonCol) 
{ 
    if (btn.getAttribute("value") == "Report") 
    { 
     btn.click(); 
     break; 
    } 
} 
0

你的回答救了我,我只是修改了一下,并没有使用它的mshtml。 这是使用它如何IM:

 WebBrowser wb = webBrowser1; 
     var doc = wb.Document; 
     HtmlElementCollection el = doc.GetElementsByTagName("input"); 
     foreach (HtmlElement btn in el) 
     { 
      if (btn.GetAttribute("value") == "Report") 
      { 
       btn.InvokeMember("click"); 
       break; 
      } 
     } 

你就像大日Thnx