Blog of Tejas Shirodkar

A Date with GeckoFx and InvokeMember(“click”);

by on Aug.04, 2009, under Development

A lot of people have been coming to my blog looking for information on GeckoFx mostly through a google search. I was successfully able to integrate GeckoFx into my crawler like app with some initial hiccups in place of the web browser 2.0 component. Although the web component exposes all functionality properly, it wasn’t enough for my needs. GeckoFx has alot of unexposed area’s and could do with a major upgrade. Anyhow I thought I would share some fixes I made or hacks I ended up with to fix some problems…

There were alot of fixes i had to do (to the code not GeckoFx) and I still haven’t been able to figure out how to get the content or the source code inside a frame or add security exceptions. One particular problem lots of people search for is the replacement for the InvokeMember(“click”) on a HtmlElement. The solution  i came across uses javascript. It’s basically like this –


geckoWebBrowser.Navigate( "javascript:void( document.getElementById( 'idOfElement' ).click() ) ");

where idOfElement is the element you want the click to be called on. Now in case the id is not available you can search for it by name or basically go through the whole file using javascript to get to your element.

I was also looking for a way to make changes to some settings like the about:config page on some extensive googling I came across Skybound.Gecko.GeckoPreferences you can change the user and default settings through this class at the time of initialization or at a later stage. So basically if you want to disable the warning for entering a secured site you would do –


Skybound.Gecko.GeckoPreferences.User["security.warn_entering_secure"] = false;

There were some other minor things here and there as well, but on those I’ll get to at a later time. In case there is somethings someone wants to know or knows of some better ways then kindly leave a comment or mail me, I’ll be glad to hear from you 🙂

Update [Sept’ 1st 2009]

In case you need to use proxy to connect you can use the following code in your C# program. It can be used at any time in the point of execution and the next call to Navigate will use the new proxy configuration.


Skybound.Gecko.GeckoPreferences.User["network.proxy.http"] = "x.x.x.x";
Skybound.Gecko.GeckoPreferences.User["network.proxy.http_port"] = 8000;
Skybound.Gecko.GeckoPreferences.User["network.proxy.socks"] = "x.x.x.x";
Skybound.Gecko.GeckoPreferences.User["network.proxy.socks_port"] = 8000;
Skybound.Gecko.GeckoPreferences.User["network.proxy.socks_remote_dns"] = true;
Skybound.Gecko.GeckoPreferences.User["network.proxy.ssl"] = "x.x.x.x";
Skybound.Gecko.GeckoPreferences.User["network.proxy.ssl_port"] = 8000;
Skybound.Gecko.GeckoPreferences.User["network.proxy.type"] = 1;

You should replace x.x.x.x with the ip pf the proxy server, and 8000 with the port which is used for proxy in each case.

For network.proxy.type, the following values can be used :

0 – Direct connection, no proxy. (Default)

1 – Manual proxy configuration.

2 – Proxy auto-configuration (PAC).

4 – Auto-detect proxy settings.

5 – Use system proxy settings (Default in Linux).

:
27 comments for this entry:

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!