Question

There is a site for food reservation that i use to reserver food. I want to automate the reservation. There is a form with 7 checkboxes each for one day of the week. I get the checkboxes and check the days that I want and after that click the submit button. The problem is when checkboxes get checked but the food but after clicking the button when the page reloads the checkboxes are not checked (this means that the food isnt reserved). Actually this is what i do with any usual browser and the checkboxes are cheched after reload of the page. there is a problem with checking the checkboxes. Ive tried these codes for checking them:

element.SetAttribute("checked", "checked");
element.InvokeMember("Click");

also when program is running if i do click myself (not using code) it works but if i check 2 checkboxes with code and another one myself it doesnt work as well.

Was it helpful?

Solution

The page designer had some functions on mousedown and mouseup events on the label for the checkbox and some functions get called inside them not mousedown and mouseup events of the checkbox.

<span style="display:inline-block;text-decoration:none;height:21px;">
<input id="chk3" type="checkbox" name="chk3" checked="checked">
<label for="chk3">Tuesday</label>
</span>

so I invoked the click for the label next to checkbox and it worked!

HtmlElement element; //points to the checkbox
HtmlElement label = element.NextSibling;
label.InvokeMember("click");

I found that some javascript functions where in another file like

<script src="/WebResource.axd?d=a9EVQm7rLRaKIS8apQBSZw2&amp;t=634596512855689274" type="text/javascript"/>

I tought maybe WebBrowser is not loading the files linked to html but i was wrong. It loades all files.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top