Hi Andre,<div><br></div><div>Comments inline.<br><br><div class="gmail_quote">On Fri, Jan 6, 2012 at 3:36 PM, Andre Klapper <span dir="ltr"><<a href="mailto:ak-47@gmx.net">ak-47@gmx.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<div class="im"><br>
On Fri, 2012-01-06 at 10:34 -0800, Nagappan Alagappan wrote:<br>
> On Fedora 16, I tried like this:<br>
> launchapp('gedit', lang = 'de_DE')<br>
><br>
> it worked as expected. I haven't used setlocale. Can you please verify<br>
> the above and see it works in your environment ?<br>
<br>
</div>Thanks nags, this works perfectly!<br>
<br>
Now I'm trying this in Czech (open gedit in Czech and close it by going<br>
to File>Quit which is Soubor>Ukončit in Czech):<br>
<br>
launchapp('gedit', lang = 'cs_CZ.utf8')<br>
time.sleep (3)<br>
selectmenuitem ('*gedit', 'mnuSoubor;mnuUkončit') # File > Quit<br></blockquote><div><br></div><div>The following issue was bug in LDTP. I have now fixed in git head and the above scenario works. </div>
<div><br></div><div>I would write the above code as:</div><div><br></div><div>launchapp('gedit', lang = 'cs_CZ.utf8')</div><div>waittillguiexist('*gedit')</div><div>selectmenuitem ('*gedit', 'mnuSoubor;mnuUkončit') # File > Quit</div>
<div>waittillguinotexist('*gedit')</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
This triggers the following error:<br>
<br>
Traceback (most recent call last):<br>
File "/usr/lib/python2.7/site-packages/pyatspi/registry.py", line 193, in eventWrapper<br>
return callback(event)<br>
File "/usr/lib/python2.7/site-packages/ldtpd/waiters.py", line 105, in _event_cb<br>
self.event_cb(event)<br>
File "/usr/lib/python2.7/site-packages/ldtpd/waiters.py", line 340, in event_cb<br>
if self._match_name_to_acc(self._frame_name, event.source):<br>
File "/usr/lib/python2.7/site-packages/ldtpd/utils.py", line 463, in _match_name_to_acc<br>
_ldtpize_accessible_name[1])<br>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 5: ordinal not in range(128)<br>
Traceback (most recent call last):<br>
File "/usr/lib/python2.7/site-packages/pyatspi/registry.py", line 193, in eventWrapper<br>
return callback(event)<br>
File "/usr/lib/python2.7/site-packages/ldtpd/core.py", line 118, in _event_cb<br>
win_name = u'%s%s' % (abbrev_role, abbrev_name)<br>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 5: ordinal not in range(128)<br>
Traceback (most recent call last):<br>
File "/usr/lib/python2.7/site-packages/ldtpd/waiters.py", line 85, in _timeout_cb<br>
self.poll()<br>
File "/usr/lib/python2.7/site-packages/ldtpd/waiters.py", line 336, in poll<br>
gui, _window_name = self._get_window_handle(self._frame_name)<br>
File "/usr/lib/python2.7/site-packages/ldtpd/utils.py", line 804, in _get_window_handle<br>
if self._match_name_to_acc(window_name, gui):<br>
File "/usr/lib/python2.7/site-packages/ldtpd/utils.py", line 463, in _match_name_to_acc<br>
_ldtpize_accessible_name[1])<br>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 5: ordinal not in range(128)<br>
Traceback (most recent call last):<br>
File "/usr/lib/python2.7/site-packages/pyatspi/registry.py", line 193, in eventWrapper<br>
return callback(event)<br>
File "/usr/lib/python2.7/site-packages/ldtpd/waiters.py", line 105, in _event_cb<br>
self.event_cb(event)<br>
File "/usr/lib/python2.7/site-packages/ldtpd/waiters.py", line 340, in event_cb<br>
if self._match_name_to_acc(self._frame_name, event.source):<br>
File "/usr/lib/python2.7/site-packages/ldtpd/utils.py", line 453, in _match_name_to_acc<br>
if <a href="http://acc.name" target="_blank">acc.name</a> == name:<br>
File "/usr/lib/python2.7/site-packages/pyatspi/Accessibility.py", line 177, in <lambda><br>
<a href="http://Atspi.Accessible.name" target="_blank">Atspi.Accessible.name</a> = property(fget=lambda x: exwrap(Atspi.Accessible.get_name, x))<br>
File "/usr/lib/python2.7/site-packages/pyatspi/Accessibility.py", line 154, in exwrap<br>
raise LookupError<br>
LookupError<br>
<br>
<br>
As I have no idea how to fix (telling Python to interpret as UTF-8 or<br>
so?) I instead tried accessing an menuitem via using an index:<br>
<br>
launchapp('gedit', lang = 'de_DE.utf8')<br>
time.sleep (3)<br>
selectmenuitem ('*gedit', 'mnu1;mnu1')<br></blockquote><div><br></div><div>launchapp('gedit', lang = 'de_DE.utf8')</div><div>waittillguiexist('*gedit') </div><div>selectmenuitem ('*gedit', 'mnu#9') # For Quit</div>
<div><div>waittillguiexist('*gedit')</div></div><div><br></div><div>Note the hierarchy number is based on accessibility output.</div><div><br></div><div>How to get the object index:</div><div><br></div><div>getobjectproperty('window name', 'object name', 'obj_index')</div>
<div><br></div><div>example:</div><div>getobjectproperty('*gedit', 'mnuQuit', 'obj_index')</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
This probably only works for objects without labels, as I get this error?:<br>
<br>
Traceback (most recent call last):<br>
File "dummie.py", line 24, in <module><br>
selectmenuitem ('*gedit', 'mnu1;mnu1')<br>
File "/usr/lib/python2.7/site-packages/ldtp/client.py", line 65, in __call__<br>
return self.__send(self.__name, args)<br>
File "/usr/lib/python2.7/xmlrpclib.py", line 1575, in __request<br>
verbose=self.__verbose<br>
File "/usr/lib/python2.7/site-packages/ldtp/client.py", line 180, in request<br>
raise LdtpExecutionError(e.faultString.encode('utf-8'))<br>
ldtp.client_exception.LdtpExecutionError: Unable to find object name "mnu1" in application map<br>
<br>
<br>
My problem is likely similar to<br>
<a href="http://lists.freedesktop.org/archives/ldtp-dev/2009-October/000923.html" target="_blank">http://lists.freedesktop.org/archives/ldtp-dev/2009-October/000923.html</a><br>
- I would like to start the same application in several different human<br>
languages by looping over some locales, and perform the same steps<br>
everytime, and would like to use a language-independent way to access<br>
objects (either via somehow defining that for object-related commands in<br>
the script the en_US default shall be looked up while still showing the<br>
user interface in a different language; or by using "generic" names for<br>
objects, like indexes, that are language-independent).<br>
<br>
Any ideas, or is this not doable currently?<br></blockquote><div><br></div><div>Above one works, but I recommend to do this way:</div><div><br></div><div>Use variable name in the script and import appropriate locale file which has same variable name mapping with respective locale string.</div>
<div><br></div><div>example:</div><div><br></div><div>gedit_cs_CZ.py will have the following entries:</div><div><br></div><div><span class="Apple-style-span" style>mnuFile = mnuSoubor</span></div><div><span class="Apple-style-span" style>mnuQuit = mnuUkončit</span></div>
<div><span class="Apple-style-span" style><br></span></div><div>gedit_de_DE.py will have similar entries as above, but with appropriate locale string as value.</div><div><br></div><div><span class="Apple-style-span" style>In actual test file:</span></div>
<div><span class="Apple-style-span" style><br></span></div><div><span class="Apple-style-span" style>import imp</span></div><div><span class="Apple-style-span" style><br></span></div><div><font class="Apple-style-span" color="#222222" face="arial, sans-serif">languages = ['cs_CZ', 'de_DE']</font></div>
<div><font class="Apple-style-span" color="#222222" face="arial, sans-serif">for lang in languages:</font></div><div><font class="Apple-style-span" color="#222222" face="arial, sans-serif"> moduleName = </font><span class="Apple-style-span" style="color:rgb(34,34,34);font-family:arial,sans-serif">'gedit_%s' % lang</span></div>
<div><font class="Apple-style-span" color="#222222" face="arial, sans-serif"> locals()[</font><span class="Apple-style-span" style="color:rgb(34,34,34);font-family:arial,sans-serif">moduleName</span><span class="Apple-style-span" style="color:rgb(34,34,34);font-family:arial,sans-serif">] = __import__(moduleName)</span></div>
<div><font class="Apple-style-span" color="#222222" face="arial, sans-serif"> launchapp('gedit', lang = lang)</font></div><div><font class="Apple-style-span" color="#222222" face="arial, sans-serif"> waittillguiexist('*gedit')</font></div>
<div><font class="Apple-style-span" color="#222222" face="arial, sans-serif"> selectmenuitem('*gedit', '%s;%s' % (mnuFile, mnuQuit))</font></div><div><font class="Apple-style-span" color="#222222" face="arial, sans-serif"><br>
</font></div><div><font class="Apple-style-span" color="#222222" face="arial, sans-serif">Hope the above code helps to start with automation.</font></div><div><font class="Apple-style-span" color="#222222" face="arial, sans-serif"><br>
</font></div><div>Thanks</div><div>Nagappan</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
My long-term aim is to have some script for localized screenshot<br>
generation for e.g. release notes, by the way.<br>
<br>
Thanks,<br>
andre<br>
<div class="HOEnZb"><div class="h5">--<br>
mailto:<a href="mailto:ak-47@gmx.net">ak-47@gmx.net</a> | failed<br>
<a href="http://blogs.gnome.org/aklapper" target="_blank">http://blogs.gnome.org/aklapper</a><br>
<br>
_______________________________________________<br>
LDTP-dev mailing list<br>
<a href="mailto:LDTP-dev@lists.freedesktop.org">LDTP-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/ldtp-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/ldtp-dev</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Linux Desktop (GUI Application) Testing Project - <a href="http://ldtp.freedesktop.org">http://ldtp.freedesktop.org</a><br><a href="http://nagappanal.blogspot.com">http://nagappanal.blogspot.com</a><br>
</div>