dogtail-devel Determine if a gui component is selectable
- From: "Anand Subramanian" <anand harihara gmail com>
- To: dogtail-devel-list gnome org
- Subject: dogtail-devel Determine if a gui component is selectable
- Date: Mon, 24 Sep 2007 12:07:04 +0300
Hi,
We use the following bit of code, seems to work fine - please do mail back if you face any problems.
It has some extra code just to print out the state-names and not just numbers off the node's stateSet.
It returns a tuple because we re-use it to print out the message in the unittest framework that we have.
Please find below the code, testcode and output.
Thanks and regards,
Anand
########################################### Code
statesDict={}
for k,v in [(key,val) for (key,val) in atspi.__dict__.iteritems() if key.find('STATE') != -1] : statesDict[v]=k.replace('SPI_STATE_','')
def checkState(node, *states):
"""
Checks if node is in given states. Even if one state is not present then check fails
Returns tuple of two elements - 1st:Result Status(True/False) , 2nd:Result String
"""
stat=True ; failedStates=[]
for state in states :
if not node.stateSet.contains(atspi.__getattribute__('_'.join(('SPI_STATE',state.upper())))) :
stat=False
failedStates.append(state)
stateSetList=str(node.stateSet).lstrip('[ ').rstrip('] ').split(',') # cannot iterate over stateSet as-is !!
presentStates=[]
for i in stateSetList :
presentStates.append(statesDict[int(i)].lower())
msgstr=' ; Node\'s stateSet='+ str(node.stateSet) + '-' + ",".join(presentStates)
if not stat :
return (False, '\n\tNode not ' + ','.join(failedStates) + msgstr+'\n\t('+str(node)+')')
else:
return (True, '\n\tNode is ' + ','.join(states) + msgstr+'\n\t('+str(node)+')')
###################### test code
ret, msg = checkState(tree.root.menu
('Applications'), 'pressed', 'focused', 'enabled', 'sensitive')
print msg
###################### output
Node not pressed,focused ; Node's stateSet=[8, 21, 23, 24, 29]-enabled,selectable,sensitive,showing,visible
({"Applications" menu})
On 9/21/07, dogtail-devel-list-request gnome org <
dogtail-devel-list-request gnome org> wrote:Send dogtail-devel-list mailing list submissions to
dogtail-devel-list gnome org
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.gnome.org/mailman/listinfo/dogtail-devel-list
or, via email, send a message with subject or body 'help' to
dogtail-devel-list-request gnome org
You can reach the person managing the list at
dogtail-devel-list-owner gnome org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of dogtail-devel-list digest..."
Today's Topics:
1. [RFC] Determine if a gui component is selectable (Cole Robinson)
2. [Bug 478984] New: dogtail-run-headless fails when trying to
run example scripts (dogtail (bugzilla.gnome.org))
----------------------------------------------------------------------
Message: 1
Date: Fri, 21 Sep 2007 10:23:42 -0400
From: Cole Robinson <crobinso redhat com>
Subject: dogtail-devel [RFC] Determine if a gui component is
selectable
To:
dogtail-devel-list gnome org
Message-ID: <46F3D3EE 9040707 redhat com>
Content-Type: text/plain; charset=us-ascii
Hey all,
A feature that would be really handy in dogtail is the ability to
determine if a gui component is selectable/focusable or visible. An
example would be to ensure that a selected radio button activates an
associated text field: we could use this feature to be sure the text
field is then selectable.
The Node object can be used to glean some of this info with its
'showing' and 'focusable' fields, but it is rather low level (the api
doesn't seem to encourage manipulating nodes directly) and can not
cleanly be used to determine if a component is _not_ selectable as a
Node cannot be assigned to a frame or window that hasn't popped up/been
created yet.
There are 2 ways I see to solve this:
1) Extend the existing 'Focus' capability from the procedural api to
to return a boolean value representing if the component was focused
or not. This is non-intrusive, fits well with an automated testing
infrastructure, and is an easy fix. One could just attempt to focus
on the component in question and easily determine if it is present
and focusable. This could be a problem though as it is specific to
the procedural API.
2) Add utility functions to specifically test a component for
visibility etc. This would have the benefit of being useful
for all APIs, but would be more code, and most likely a pain
as we would need individual functions for each type of gui
component (isWindowVisible, isButtonVisible ...) or have
guesswork complexity to accomodate for that.
I'm leaning towards #1, but looking for input. Anyone have any ideas, or
maybe something I've missed?
Thanks,
Cole
--
Cole Robinson
crobinso redhat com
------------------------------
Message: 2
Date: Fri, 21 Sep 2007 14:46:10 +0000 (UTC)
From: "dogtail (
bugzilla.gnome.org)"
<bugzilla-daemon bugzilla gnome org>
Subject: dogtail-devel [Bug 478984] New: dogtail-run-headless fails
when trying to run example scripts
To: dogtail-devel-list gnome org
Message-ID: <bug-478984-64182 http bugzilla gnome org/>
Content-Type: text/plain; charset=utf-8
If you have any questions why you received this email, please see the text at
the end of this email. Replies to this email are NOT read, please see the text
at the end of this email. You can add comments to this bug at:
http://bugzilla.gnome.org/show_bug.cgi?id=478984
dogtail | Examples | Ver: 0.6.1
Summary: dogtail-run-headless fails when trying to run example
scripts
Product: dogtail
Version: 0.6.1
Platform: Other
OS/Version: All
Status: UNCONFIRMED
Severity: normal
Priority: Normal
Component: Examples
AssignedTo: dogtail-maint gnome bugs
ReportedBy: crobinso redhat com
QAContact:
dogtail-maint gnome bugs
GNOME version: Unspecified
GNOME milestone: Unspecified
Please describe the problem:
dogtail-run-headless fails in Fedora 7. The example scripts run on their own so
its not a problem with them.
# dogtail-run-headless -n ./gedit-test-utf8-procedural-api.py
xinit /tmp/dogtail-headless-xinitrc.8517 -- /usr/bin/Xvfb :1 -screen 0
1024x768x16 -ac -noreset -shmem
screen 0 shmid 1015824
GTK Accessibility Module initialized
** (metacity:8526): WARNING **: AT_SPI_REGISTRY was not started at session
startup.
** (metacity:8526): WARNING **: IOR not set.
** (metacity:8526): WARNING **: Could not locate registry
Creating logfile at
/tmp/dogtail/logs/gedit-test-utf8-procedural-api_20070921-102536_debug ...
Creating logfile at
/tmp/dogtail/logs/gedit-test-utf8-procedural-api_20070921-102536_results ...
Detecting distribution: Fedora (or derived distribution)
** (process:8528): WARNING **: AT_SPI_REGISTRY was not started at session
startup.
** (process:8528): WARNING **: Could not locate registry
GTK Accessibility Module initialized
** (gedit-test-utf8-procedural-api.py
:8528): WARNING **: AT_SPI_REGISTRY was
not started at session startup.
** (gedit-test-utf8-procedural-api.py:8528): WARNING **: IOR not set.
** (gedit-test-utf8-procedural-api.py:8528): WARNING **: Could not locate
registry
(gedit-test-utf8-procedural-api.py:8528): Bonobo-CRITICAL **:
bonobo_unknown_ping: assertion `object != NULL' failed
** (gedit-test-utf8-procedural-api.py:8528): WARNING **: AT_SPI_REGISTRY was
not started at session startup.
** (gedit-test-utf8-procedural-api.py:8528): WARNING **: Could not locate
registry
Traceback (most recent call last):
File "./gedit-test-utf8-procedural-api.py", line 9, in <module>
from dogtail.procedural import *
File "/usr/lib/python2.5/site-packages/dogtail/procedural.py", line 18, in
<module>
import tree
File "/usr/lib/python2.5/site-packages/dogtail/tree.py", line 1247, in
<module>
root = Root (atspi.registry.getDesktop ())
File "pyspi.pyx", line 195, in atspi.Registry.getDesktop
File "pyspi.pyx", line 152, in atspi.exception_handler
SpiException: Non-fatal SPIException: type:0 source:0
"IDL:omg.org/CORBA/INV_OBJREF:1.0"
Steps to reproduce:
1.
2.
3.
Actual results:
Expected results:
Does this happen every time?
Other information:
# rpm -q dogtail pyspi
dogtail-0.6.1-1.fc7
pyspi-0.6.1-4.fc8
Also saw this on stock F7 dogtail and pyspi (this output is from rawhide)
--
See
http://bugzilla.gnome.org/page.cgi?id=email.html for more info about why you received
this email, why you can't respond via email, how to stop receiving
emails (or reduce the number you receive), and how to contact someone
if you are having problems with the system.
You can add comments to this bug at http://bugzilla.gnome.org/show_bug.cgi?id=478984.
------------------------------
_______________________________________________
dogtail-devel-list mailing list
dogtail-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/dogtail-devel-list
End of dogtail-devel-list Digest, Vol 24, Issue 1
*************************************************
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]