Using Selenium WebDriver in custom extension - webdriver

I am developing a Firefox extension and have a need to generate synthetic events. I want this events to be treated as 'native' events. However, the DOM APIs exposed by Firefox (createEvent, initEvent) aren't really behaving as native events. I realized Selenium solved the issue by adopting native events.
My question is, can I use webdriver.xpi standalone within my extension? My extension is JavaScript based. If yes, how? Has anyone done it before?
Any pointers will be highly appreciated.

Selenium is unnecessary:
You can use nsIDOMWindowUtils.sendMouseEventToWindow() instead of document.createEvent(). This method is meant for testing and will generate a native event as well.
References
Are events generated by Firefox extension 'trusted'?

Related

Web-scraping in node.js in order to get all the CSS properties which are applied to each element of a web page

I would like to find a web-scraping technique based on node.js in order to get all the CSS properties which are applied to each element of a web page as the firebug does.
I tried to use jsdom by using the getMatchedCSSRules() but it seems that it doesn't work correctly. I think that's happening because the HTML content which I get by doing a GET request to a URL (i.e https://stackoverflow.com), it doesn't get rendered as it does in a web browser.
Does anybody know a way to do this in the node.js back-end part of an application?
For 100% emulating browser, you can't use a plain Node.js solution. You need use WebDriver + Node.js.
With WebDriver you have getCssProperty method.
Does this solution work for you?

How to unregister TdxPNGImage as a property handler?

I am using Delphi XE2. I have Dev Express 12 installed and use it for some projects.
However I have projects where I do not use DevExpress at all, and I wanted for those to not have any dependency on it.
When I assign a PNG image to any TPicture property on Object Inspector it always use a TdxPNGImage class to handle it.
That cause to add the unit dxGDIPlusClasses creating dependency on having DevExpress installed.
But I need to not break DevExpress on my Delphi. It must continue to work for those projects based on it and that eventually will need this png class.
Somehow I have missed the answer of this on DevExpress forum, even after many searches.
I am posting here the link for the issue and possible solutions:
Delphi 2010 always uses the TdxPNGImage class for loading PNG images (this corrupts form streaming)
I have tested and it works.

Swfaddress and IE8

Has anyone successfully gotten swfaddress to work with IE8 and above?
It seems that when using standards mode, swfaddress will appear to work fine in IE8 and IE9, however, once the user modifies the hashtag in the address bar, the history list becomes corrupted.
In cases where the user starts the application via the hash tag (http://myapp.com/#/test), and then visits another hash (http://myapp.com/#/test1), the history is never saved.
I have tried playing around with swfaddress 2.5 in the svn repository. Interestingly,
the code is similiar to JQuery Address (by the same author). I also note that JQuery Address suffers from the same problem.
If I turn on compatibility mode in IE, the swfaddress and JQuery Address works perfectly. I have been looking into how compatiblilty mode works, and it does not seem like it would modify or affect javascript execution.
Was anyone able to successfully solve this issue? If not are there any other deep linking libraries for flex or flash that contains all the feature sets of swfaddress?
After looking at libraries such JQuery Address, other JQuery state management plugins and even the BrowserManager that ships with Flash and Flex builder, I discovered that they all ran into the same issue as SwfAddress.
At the moment, SwfAddress offers that best features and comes with a .swc and .as files to easily interface with Flash and Flex applications.
Since the other javascript libraries ended up with the same problems, I have decided to stick with SwfAddress.
On a related note, the author has stated that he is no longer working on SwfAddress, so it would be cool if someone in the community can pick up on where it was left off.

How do I set Hotkeys in Flex?

I'm new to Flex and i want to bind STRG+I to trigger a function.
How do i do that ?
Well, there's different things. I haven't personally done it yet, so after checking some Adobe documentation here what I found.
One can use flash.ui.Keyboard class in order to have a full keyboard control for your application. That would mostly require AIR tho, since the hotkeys are quite limited inside a browser.
In the case you're not in AIR, but in the flash player sitting in the browser, you can do it using simple event handling. Here's some nice tutorial how to do it:
http://tutorials.flashmymind.com/2009/02/actionscript-3-keyboard-events/
Hope it helps!

Which Javascript history back implementation is the best?

There are implementations for history.back in Micrososft AJAX and jQuery (http://www.asual.com/jquery/address/).
I already have jQuery and asp.net ajax included in my project but I am not sure which implementation of history.back is better.
Better for me is:
Already used by some large projects
Wide browser support
Easy to implement
Little footprint
Does anybody know which one is better?
EDIT:
Another jquery plugin is http://plugins.jquery.com/project/history It is recommmended in the book JQuery Cookbook. This one worked well so far.
One alternative to jQuery Address is the nice jQuery history plugin. There are also URL Utils.
Reference: AJAX History and Bookmarks.
If you are building an ASP.NET application then using ASP.NET Ajax Framework gives you many advantages and a nice-simple API to use server-side.
Below you can find an example that uses Browser History with ASP.NET Ajax
Create a Facebook-like AJAX image gallery
Both have a wide range support in browsers.
For me is easier to integrate Microsoft AJAX Framework in an ASP.NET page so again if you have an .aspx page it might be easier to work with ASP.NET AJAX
If you don't need exactly AJAX, i.e. updating only parts of the site on request is sufficient for you, then you can use invisible iframe as target for loading generated HTML file containing only JS script that updates/resets "updateable" parts of the site. This is cross-browser solution and doesn't need address polling.
Example, but not in ASP: kociszkowo.pl (Polish site)
When you click there in the section icon and your browser supports javascript, link is modified before being fetched - target is changed to iframe and href is suffixed with .dhtml to inform server, that we're interested in a special version of the page. If you press Back in your js-equipped browser, then previously fetched iframe page is loaded from the cache. Simple, but requires some decisions at architectural level.
This link modification is irrelevant here, it's just the result of combining JS/non-JS world.
In my experience, your best bet is using the same one that you have doing most (if not all) of your ajax calls. For instance, if you're using asp:UpdatePanel's, use the MS one - if you're using jQuery.ajax, use the jQuery history plugin. If you're doing a mix (which I've tried to avoid in my projects), I'd personally test with both and see which behaves better - if they both test fine, then it's a bit of preference. Some may argue the Microsoft one would have better support, but jQuery's history plugin may get more use and more mature.
http://msdn.microsoft.com/en-us/library/system.web.ui.updatepanel.aspx
http://docs.jquery.com/Ajax/jQuery.ajax#options

Resources