C#webbrowser 多个form表单 选择其中一个提交 来个高手

  <form method="post" action="/gp/item-dispatch/ref=olp_atc_new_2" class="a-spacing-none">
                <input type="hidden" name="session-id" value="147-3113226-4993231">
                <input type="hidden" name="qid">
                <input type="hidden" name="sr">
                <input type="hidden" name="signInToHUC" value="0" id="signInToHUC">
                <input type="hidden" name="metric-asin.B011MYEMKQ" value="1">
                <input type="hidden" name="registryItemID.1">
                <input type="hidden" name="registryID.1">
                  <input type="hidden" name="itemCount" value="1">
                <input type="hidden" name="offeringID.1" value="xXgcZtPBgpFHeUzpX2V7SNk9CfHhhXhyLioVQ%2FwdUcLYBorDSaBIDRa3rxB%2B2CLtApICpC4QCMcejhjG5ARwqRNSnlondz%2BxyqSxF1m7iiPyCS6Fab0EwYwZe0J1sAxYETAhIfWeye1fT2ySUEgi4pJTZvbJ27Qn">
                <input type="hidden" name="isAddon" value="1">

                  <span class="a-declarative" data-action="olp-click-log" data-olp-click-log="{&quot;subtype&quot;:&quot;main&quot;,&quot;type&quot;:&quot;addToCart&quot;}">
                             <span class="a-button a-button-normal a-spacing-micro a-button-primary a-button-icon"><span class="a-button-inner"><i class="a-icon a-icon-cart"></i><input name="submit.addToCart" class="a-button-input" type="submit" value="Add to cart"><span class="a-button-text" aria-hidden="true">
                                Add to cart
                                <span class="a-offscreen"">from seller Lacey Lane and price $29.99</span>

                             </span></span></span>
                  </span>
          </form>

                    </span></span></span>
                  </span>
          </form>




                    多个form表单相同   唯一不同的是每一个表单的action的值不一样
                      <span class="a-offscreen"">from seller Lacey Lane and price $29.99</span>

                        这一个也不一样   求大神    这样的表单 在一个页面可能有好几十个  我想匹配一个 然后点击

这不是很简单,js提交不久行了

使用JS 组建一个form表单,把界面数据通过JS发送给服务器

获取表单遍历,对比action找到你需要提交的表单触发表单
https://www.cnblogs.com/pingming/p/4115222.html
提交表单
https://www.cnblogs.com/yuanjw/archive/2007/06/26/796009.html

思路是这样,有多个form, 要提交哪个form就调用哪个form的submit方法,示例
<!DOCTYPE html>




<br> function submitSelectedForm() {<br> var formSelector = document.getElementById(&quot;formSelector&quot;);<br> if (formSelector.value === &quot;1&quot;) {<br> document.forms[&quot;form1&quot;].submit();<br> }<br> else if (formSelector.value === &quot;2&quot;) {<br> document.forms[&quot;form2&quot;].submit();<br> }<br> }</p> <pre><code>&lt;/script&gt; </code></pre> <p></head><br> <body><br> <form name="form1" action="FormProcess1.aspx" method="post"><br> <input type="text" name="txtSource" /><br> </form></p> <pre><code>&lt;form name=&quot;form2&quot; action=&quot;FormProcess2.aspx&quot; method=&quot;post&quot;&gt; &lt;input type=&quot;text&quot; name=&quot;txtSource&quot; /&gt; &lt;/form&gt; &lt;label for=&quot;formSelector&quot;&gt;选择:&lt;/label&gt; &lt;select id=&quot;formSelector&quot; &gt; &lt;option selected value=&quot;1&quot;&gt;form1&lt;/option&gt; &lt;option value=&quot;2&quot;&gt;form2&lt;/option&gt; &lt;/select&gt; &lt;input type=&quot;button&quot; onclick=&quot;submitSelectedForm()&quot; value=&quot;提交&quot; /&gt; </code></pre> <p></body><br> </html></p>

我看到form表单是个嵌套的,如果要嵌套别设置action,要不然会有问题。
想用js模拟提交可以动态设置action,这样只用一个form就可以动态提交不同的action,下载一个jquery.form.js,百度有教程。

foreach(HtmlElement e in webBrowser1.Document.Forms)
{
if((HTMLFormElement)(e)).Action="你要选择的form")
{
((HTMLFormElement)(e)).submit();
}
}