[Pythonmac-SIG] Appscript Python module / Applescript to python conversion

Ned Deily nad at acm.org
Thu Oct 9 20:21:35 CEST 2008


In article 
<E19E8F331620EC4682A1530C6DF9B02A465204 at WEBEXCHANGE02.webde.local>,
 Martin Tönnishoff <Martin.Toennishoff at 1und1.de> wrote:
> Can you please help me to get this right? How do I convert a string to the 
> required "unicode_text" type wich is noth
> the python builtin one. 

The error message is misleading you.  The problem is not the string; 
it's that you are not targeting the correct reference.

[...]
> safari.document.URL.set("http://www.google.de")
> 
> #wait for browser to open page
> foo = 5 + int(random.random()*10)
> time.sleep(foo)
> 
> #do some javascript manipulation on the loaded page
> jscript= u"window.alert('foo');"
> 
> safari.do_JavaScript(jscript)

You need a reference to the specific document not to the application:

    safari.document.do_JavaScript(jscript)

-- 
 Ned Deily,
 nad at acm.org



More information about the Pythonmac-SIG mailing list