Archive for the ‘Ruby’ tag
Possibly the third attempt to start using this.
Yo.
Well, as everyone who has a blog is aware, its hard to actually find anything to put in it, never mind actually remembering to write it.
Ok, so personal stuff. Started my studentship at Lancaster University within the EIS(http://eis.comp.lancs.ac.uk) research group. Still unsure of an actual topic, although I will probably swing towards the algorithmic side of localisation in WSN.
Still, I rarely have time to do any personal code, yet some stuff happens. Recently wrote a basic heightmap generator in Ruby, currently porting to Lua, and it outputs some nice images using image tools like RMagick or just plain VT100 colour output.
Post to follow explaining the code.
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?
# 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