Question

I'm very new to C# and programming overall. In my first WinForms app I used standart WebBrowser but I encountered a lot of problems that are related to Internet Explorer so I started to look for alternatives and found Awesomium. I move very very slow in understanding how it works and right now I've encountered a sirious problem that doesn't allow me to continue and makes me go back to using standart C# WebBrowser. Here's the code of button I need to click:

<span class="r-button r-button_h36 r-input_w200 r-button_graphite" title="Submit" draggable="false" onclick="_gaq.push(['_trackEvent', 'Registration', 'Click_next_button']);">Submit`<input class="r-button_invisible" name="button.submit" type="submit" value="" tabindex="1"`></span>

I've googled the solution for all night long but no luck. Already tried using javascripts:

cbrowser.ExecuteJavascript("document.getElementsByTagName('button.submit')[0].click();");

And a lot of variations of it with no luck.

Was it helpful?

Solution

Some times I have to perform all the 3 actions to get the button clicked:

// Make sure the web browser is on focus
webView.Focus();
// Find and click the button
webView.ExecuteJavascript("document.getElementsByName('button.submit')[0].click();");
// Update the web browser
WebCore.Update();

And sometimes it takes awhile for awesomium to update its stuff or the update is without switching pages(dynamically) and awesomium doesn't have a good DOM control for that as in the navigating status and stuff would not help.

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