Main Site login Signup

[SOLVED] Unable to execute js code on a website in console application

Hallo. I have a problem with executing javascript code on a website in a console application. Javascript code is taken via awesomium wpf web control by inspecting certain html's element's onclick attribute (hence executable js code is native for the targeted website). The onclick value, which is js code, stored in a file with URL where it's expected to be invoked. In console application I create a thread, where I perform following actions: 1. make webcore running in a dedicated thread:

  WS= WebCore.CreateWebSession("../../../AwesomiumTest/bin/Debug/WebSessionData", WebPreferences.Default);//directory where cookies are stored
                         WV = WebCore.CreateWebView(1100, 600, WS);
                         WV.LoadingFrameComplete += WV_LoadingFrameComplete;

  1. Somewhere outside of dedicated thread I change WebView Source like this:

    WebCore.QueueWork(WV,()=> { WV.ExecuteJavascript(rJS.JS); });//rJS.JS);

3.WV_LoadingFrameComplete is handled like this:

  private void WV_LoadingFrameComplete(object sender, FrameEventArgs e) {
             if (e.IsMainFrame)
                 WebCore.QueueWork(WV,()=> {  WV.ExecuteJavascript(rJS.JS); });
                 Console.WriteLine("js executed");

where rJS.JS is the javascript code.

The funny thing is, I get output "js executed", yet after this every time I check changes which are expected to be on the target website aaaand nope, like nothing happened. Yet I catch no exceptions, no nothing. Can anyone help me with an advice or smth?

inb4 check awesomium basic examples for console applications: did it already, didn't help at all. Also 1: javascript code executed correctly when using WPF webcontrol, this is what grinds my gears, what's the difference between IWebView created/used by webcontrol and those that I create from WebCore.CreateWebView()? Also 2: javascript code executed correctly from g chrome browser from it's console Also 3: is it somehow possible, that websites may detect if client is using a non-regular browser and affects further js execution?



===================================================================================== Nevermind, problem is solved and it wasn't about awesomium. The problem was that js code wouln't executed before hovering on an element (either manually or programmatically, jquery 'hover' handler had to be triggered, which does idk what, but js works after that). So if anyone else to try perform some actions on a website right after main frame loaded, check in normal webbrowser (chrome, firefox, etc) that your actions are possible to perform right after page loaded without doing any mouse movement/key pressing.

asked Oct 30, 2016 at 02:04 PM avatar image theReddy 0
more ▼
(comments are locked)
10|1100 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.