c# - How can I click a checkbox using HtmlAgilityPack -
htmlagilitypack.htmldocument doc = new htmlagilitypack.htmldocument(); doc.loadhtml(webbrowser.documenttext); htmlnode n = doc.documentnode.selectsinglenode("//*[contains(@class, 'checkbox')]"); <table class="list" cellspacing="0"> <tbody> <tr> <th width="45" class="checkall"><input title="select all" class="checkbox" type="checkbox" value=""></th> <th><span>account</span></th> <th><span>target system</span></th> </tr> <tr class="checkable"> <td><input name="item1" class="checkbox" type="checkbox"></td> <td><span>sometext1</span></td> <td><span>system1</span></td> </tr> <tr class="checkable odd"> <td><input name="item2" class="checkbox" type="checkbox"></td> <td><span>sometext2</span></td> <td><span>stystem2</span></td> </tr> <tr class="foot"> <td colspan="4"><input name="submit" class="submit" type="submit" value="unlock"></td> </tr> </tbody> </table> i trying click first checkbox says "select all" other checkboxes below selected.
i think c# code suppose load htmlnode can't figure out how click it.
any suggestions helpful.
i don't think can use htmlagilitypack check checkbox. yes can change dom in doc object checkbox checked , set documenttext of webbrowser control htmldocument doubt that's want do.
if have page open in webbrowser, can use this:
webbrowser1.document.getelementsbytagname("input")[0].invokemember("click"); but select first checkbox.
if want checkboxes selected, can either iterate above code input elements or use server side javascript check checkboxes when first checkbox checked.
again, can further if explain want little bit more clearly.
Comments
Post a Comment