#!/usr/bin/env python

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

import os
import sys

driver = webdriver.Firefox()
driver.get("file://%s" % (os.path.join(os.getcwd(), "test/test_runner.html")))

WebDriverWait(driver, 10).until(
    lambda driver: driver.execute_script("return (window.webtest != undefined)"))

driver.execute_script("webtest.run()")

WebDriverWait(driver, 10).until(
    lambda driver: driver.execute_script("return webtest.finished"))

webtest = driver.execute_script("return webtest")
print webtest["log"]

driver.close()

if not webtest["passed"]:
    sys.exit(1)

@@ -20,22 +20,21 @@
 on%0A%0A
-from s
+%22%22%22%0AS
 elenium 
 impo
@@ -33,24 +33,47 @@
 ium 
-import webdriver
+test runner.%0A%22%22%22%0A%0Aimport os%0Aimport sys%0A
 %0Afro
@@ -74,33 +74,40 @@
 s%0A%0Afrom selenium
-.
+ import 
 webdriver.common
@@ -103,28 +103,8 @@
 iver
-.common.by import By
 %0Afro
@@ -160,96 +160,60 @@
 ait%0A
-from selenium.webdriver.support import expected_conditions as EC%0A%0Aimport os%0Aimport sys%0A%0A
+%0A%0Adef main():%0A    %22%22%22%0A    Main program.%0A    %22%22%22%0A    
 driv
@@ -237,16 +237,20 @@
 refox()%0A
+    
 driver.g
@@ -252,16 +252,25 @@
 ver.get(
+%0A        
 %22file://
@@ -330,16 +330,20 @@
 ml%22)))%0A%0A
+    
 WebDrive
@@ -359,32 +359,36 @@
 ver, 10).until(%0A
+    
     lambda drive
@@ -381,32 +381,44 @@
   lambda driver:
+%0A           
  driver.execute_
@@ -466,16 +466,20 @@
 ed)%22))%0A%0A
+    
 driver.e
@@ -510,16 +510,20 @@
 un()%22)%0A%0A
+    
 WebDrive
@@ -543,24 +543,28 @@
  10).until(%0A
+    
     lambda d
@@ -621,16 +621,20 @@
 hed%22))%0A%0A
+    
 webtest 
@@ -675,16 +675,20 @@
 btest%22)%0A
+    
 print we
@@ -701,16 +701,20 @@
 %22log%22%5D%0A%0A
+    
 driver.c
@@ -721,16 +721,20 @@
 lose()%0A%0A
+    
 if not w
@@ -751,16 +751,20 @@
 ssed%22%5D:%0A
+    
     sys.
@@ -771,8 +771,47 @@
 exit(1)%0A
+%0Aif __name__ == %22__main__%22:%0A    main()%0A

Tidy up python test script