March 06, 2009

Automating web workflow in Adobe AIR

This entry was created using an AIR based browser.

Yes, it's possible. I wrote a simple AIR app that signs me in to Warwick Blogs by loading the login page into an AIR app, populating the login form fields, and submitting. It's also possible to call javascript methods in the page. Here's the code:

<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="1024" height="768">

<mx:Script>
	<![CDATA[
 
			import mx.controls.Alert;
	
			private var domWindow:Object;
			private var blnAlertThrown:Boolean = false;
			private var load:int = 0;
						
	        private function initDomWindow(event:Event):void {
			if(load == 0)
			{
			load++;
	        domWindow = event.currentTarget.domWindow;
        	getElementFromHTML("userName").value = "myusername";
        	getElementFromHTML("password").value = "mypassword";
        	domWindow.document.forms[0].submit();
			}
			else
			{
				load++;
			}        	
	        }

	        private function getElementFromHTML(elementName:String):Object {
				var arrayContainingAllFoundElements:Object = domWindow.document.getElementsByName(elementName);
				return arrayContainingAllFoundElements[0];	
	        }
 	
	]]>
</mx:Script>

<mx:HTML id="htmlTranslate" x="10" y="84" location="http://blogs.warwick.ac.uk/blogbuilder/admin/create/plainEntry.spr?blog=094d4021fb4dbd6d00fb4de01b490001&amp;newPermissions=Anyone&amp;newCommentPermissions=Anyone" complete="initDomWindow(event)"/>
	
</mx:WindowedApplication>

- No comments Not publicly viewable


Add a comment

You are not allowed to comment on this entry as it has restricted commenting permissions.

Trackbacks

  1. More AIR web automation - styles and dispatching mouse events

    More experiments with creating automated workflows using the AIR html component. The following code gets the dom document once the html has loaded. It then gets a reference to a span in the document called 'edittool'. Once an element is referenced a...

    Transversality - Robert O'Toole - 08 Mar 2009, 16:18

Search this blog

Not signed in
Sign in

Powered by BlogBuilder
© MMXII