xuv's notebook

Side notes, howtos and random bits of information related to Julien Deswaef's projects

User Tools

Site Tools


workshops:moddr_workshop

Moddr worshop @ iMAL

http://moddr.net/
http://moddr.net/download
All code here is copied from this page: http://moddr.net/wiki/doku.php?id=workshop
I just added some notes to it.

installation

wget http://moddr.net/download/imal.tgz
tar -xvf imal.tgz
sudo aptitude install sun-java6-bin
sudo aptitude install openjdk-6-jre-headless
sudo aptitude install recordmydesktop

getting started cmdline

cd imal
./start_selenium.sh

Wait for the command prompt, then…

To start 2 browser windows… one for debug and another for playing around

cmd=getNewBrowserSession&1=*firefox&2=http://www.google.com

Open Google url in the browser

cmd=open&1=http://www.google.com

Enter “trollface” in the search box

cmd=type&1=name=q&2=trollface

Make it click the “Search” button

cmd=click&1=name=btnG

Copy this code below to a file.py

#!/usr/bin/python
from selenium import selenium
import unittest, time
import random
 
# selenium functions
def login_process(website):
  sel = selenium("localhost", "4441", "*chrome", website)
  sel.start()
  sel.open_window(website,"whatever")
  sel.select_window("whatever")
  sel.set_timeout(120000)
  sel.window_maximize()
  #sel.refresh()
 
  return sel 
 
login_process("http://google.com")
#!/usr/bin/python
from selenium import selenium
import unittest, time
import random
 
# selenium functions 
def login_process(website):
	sel = selenium("localhost", "6666", "*chrome", website)
	sel.start()
	sel.open_window(website,"whatever")
	sel.select_window("whatever")
	sel.set_timeout(120000)
#	sel.window_maximize()
	time.sleep(4)
	print "i am in the Internet"
	return sel
 
def kill_window(sel):
	print "done :)"
	sel.close()
 
def query(sel):
	print "do the query"
	sel.type("q_d", "rotterdam, willem buytewechstraat 188A")
	sel.click("q-sub")
	time.sleep(3)
	sel.click("//div[@id='cbctl']/div[3]/div[4]") 
	for i in range(1000):
		sel.click("//div[@id='cbctl']/div[3]/div[4]") # zooming
		sel.click("//div[@id='cbctl']/div[3]/div[4]") # zooming
		sel.click("//div[@id='cbctl']/div[3]/div[4]") # zooming
		sel.click("//div[@id='cbctl']/div[3]/div[4]") # zooming
		sel.click("//div[@id='cbctl']/div[3]/div[4]") # zooming
		sel.click("//div[@id='cbctl']/div[3]/div[4]") # zooming
		sel.click("//div[@id='cbctl']/div[3]/div[4]") # zooming
		sel.click("//div[@id='cbctl']/div[3]/div[4]") # zooming
		sel.click("//div[@id='cbctl']/div[3]/div[4]") # zooming
		sel.click("//div[@id='lmczo']/div[2]")
		sel.click("//div[@id='lmczo']/div[2]")
		sel.click("//div[@id='lmczo']/div[2]")
		sel.click("//div[@id='lmczo']/div[2]")
		sel.click("//div[@id='lmczo']/div[2]")
		sel.click("//div[@id='lmczo']/div[2]")
		sel.click("//div[@id='lmczo']/div[2]")
		sel.click("//div[@id='lmczo']/div[2]")
		sel.click("//div[@id='lmczo']/div[2]")
 
	# performing a random urban walk (petrautomata ;)
	for i in range(1000):
		# generating random number between 1 & 4
		j = random.randint(1,4)
		# this is the command for left/right/top/bottom
		cmd = """sel.click("//div[@id='compass']/div[%s]")""" %j
		# exectue the command
		eval(cmd)
		time.sleep(1)
	return sel
 
sel = login_process("http://maps.google.com/")
sel = query(sel)
 
kill_window(sel)

run firefox in background

workshops/moddr_workshop.txt · Last modified: 2011/11/02 13:10 by 91.183.83.6