[LDTP-Dev] Launch application in specific locale?

Andre Klapper ak-47 at gmx.net
Thu Jan 12 13:05:25 PST 2012


Hi Nags,

as usual thanks for your answer & your patience with me. :)

On Fri, 2012-01-06 at 18:00 -0800, Nagappan Alagappan wrote:
> How to get the object index:
> getobjectproperty('window name', 'object name', 'obj_index')
> example:
> getobjectproperty('*gedit', 'mnuQuit', 'obj_index')

Wonderful, this makes it language-independent and reusable!

> Use variable name in the script and import appropriate locale file
> which has same variable name mapping with respective locale string.
> example:
> gedit_cs_CZ.py will have the following entries:
> mnuFile = mnuSoubor
> mnuQuit = mnuUkončit

If I get it right this would require parsing all the translations first
that I plan to cover by extracting translations and add them into the
mapping file, plus it is error-prone as translations are a moving target
(work in progress), especially before a major release.

That's why I'd love to access all objects by using their index in my
script, however it seems that some objects simply don't have an index,
as the LDTP Tutorial PDF states on page 13 ("Different ways of
representing window name", item 7): "Window type and index (only if
window does not have any accessible title, Ex: 'dlg0')".

I get an error when I try to get the index of the "gedit Preferences"
dialog when going to Edit > Preferences with this code:

# -*- coding: utf-8 -*-
#!/usr/bin/python
from ldtp import *
launchapp('gedit', lang = 'en_US.utf8')
if waittillguiexist ('*gedit') == 0:
  raise LdtpExecutionError ('Application window does not exist')
print "Application window exists."
selectmenuitem ('*gedit', 'mnu#32')
if waittillguiexist ('dlggeditPreferences') == 0:
  raise LdtpExecutionError ('Dialog window does not exist')
time.sleep (3)
OBJECTINDEX = getobjectproperty('*gedit', 'dlggeditPreferences', 'obj_index')
print "obj_index for dlggeditPreferences is: "
print OBJECTINDEX

The error is:

Traceback (most recent call last):
  File "index.py", line 12, in <module>
    OBJECTINDEX = getobjectproperty('*gedit', 'dlggeditPreferences', 'obj_index')
  File "/usr/lib/python2.7/site-packages/ldtp/client.py", line 65, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1575, in __request
    verbose=self.__verbose
  File "/usr/lib/python2.7/site-packages/ldtp/client.py", line 180, in request
    raise LdtpExecutionError(e.faultString.encode('utf-8'))
ldtp.client_exception.LdtpExecutionError: Unknown property "obj_index" in dlggeditPreferences

So I guess there is no way to make my script completely avoid using any
language-dependent object names and only indexes? Sigh. :-/

andre
-- 
mailto:ak-47 at gmx.net | failed
http://blogs.gnome.org/aklapper



More information about the LDTP-dev mailing list