Monday, 5 January 2009

Ruby and Watir: Sending keyboard events to an element

Ok, so you need to send certain keyboard events to an element to properly test a webpage, but stuck how to do it?

Ive looked at some tutorials on the web, but there doesn't seem a simple solution.

However, I have been experimenting, and this method seems to work fine.

First off create your Watir::IE object

ie = Watir::IE.new

Then navigate to the page you are testing

ie.goto("mypage.myserver.com")

Grab the descriptor of the element you wish to send a keyboard command to (for example, a text field)

element = ie.textField(:id, "myText")

Now, I found that keyboard events only work if the Watir::IE window is on top and has focus, so for example if we wish to send a "Pageup" keyboard command to the element "myText" we would do so by

ie.bring_to_front
element.focus

element.container.focus
element.container.send_keys("{PGUP}")

This method does require Autoit(http://www.autoitscript.com/autoit3/) to be installed, and a full list of keyboard events can be found here: http://www.autoitscript.com/autoit3/docs/appendix/SendKeys.htm

Christmas Time

Well Christmas time has been and gone, and I must say that spending time with my family after 2 years is ... odd.

First off there are the hours they are awake. I don't mind getting up at 7am, however going to bed at 10pm? Thats the half day mark!

Catching up with childhood friends is also quite surreal. Everyone seems to regress 5 or so years back to the mentality of school children and old rivalries emerge. I don't think I shall be staying so long for Easter.

Well the last weekend has ended, and work begins anew! At least I can crawl out of bed to my office this week as working from my folks kitchen table. The joys of programming for a living.

And on the programming for a living note, I will be posting a tutorial on how to send keyboard events to elements using Watir.

Wednesday, 27 August 2008

Summer, Lisbon and Research

Well the talk in Glasgow went great, and I managed to receive a grant to visit the university of lisbon for a week in the summer to continue my research.

I managed to find some interesting results and managed to create a small java application to view my results visually.

It came out quite nice, and as such I have plenty of interesting avenues of new research for next year, including a new radio propagation method that takes into account buildings. It would help urban scenarios imensely.

Friday, 7 March 2008

MiNeMa

Well I've just been told I have to give a 15 min presentation on my research at this years MiNeMa workshop in Glasgow. Thats fine but as I'm only in my second year ... I think my hair may fall out.

I will be giving a presentation on a modified broadcast algorithm for use in Mobile Adhoc Networks.

Hope every one enjoys it!

Also, John Hardy, Steve Wattam and myself quickly prototyped a Trilateration program for use with bluetooth devices. If any one is interested in the code, or on a more robust implementation, please contact me.