summaryrefslogtreecommitdiff
path: root/ldtpd
diff options
context:
space:
mode:
authorNagappan Alagappan <nagappan@gmail.com>2012-10-15 09:58:11 -0700
committerNagappan Alagappan <nagappan@gmail.com>2012-10-15 09:58:11 -0700
commit5696e805c41ed9845bbd41a81e62b5875c718920 (patch)
treec005cd642562c7b32887f05b516020082976ba85 /ldtpd
parentc09d3683d1ce4b28fc7003a2a3668758d8753a67 (diff)
Added inserttext API
Diffstat (limited to 'ldtpd')
-rw-r--r--ldtpd/text.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/ldtpd/text.py b/ldtpd/text.py
index 94db8fe..98187fe 100644
--- a/ldtpd/text.py
+++ b/ldtpd/text.py
@@ -185,6 +185,38 @@ class Text(Utils):
return unicode(texti.getText(start, end))
+ def inserttext(self, window_name, object_name, position, data):
+ """
+ Insert string sequence in given position.
+
+ @param window_name: Window name to type in, either full name,
+ LDTP's name convention, or a Unix glob.
+ @type window_name: string
+ @param object_name: Object name to type in, either full name,
+ LDTP's name convention, or a Unix glob.
+ @type object_name: string
+ @param position: position where text has to be entered.
+ @type data: int
+ @param data: data to type.
+ @type data: string
+
+ @return: 1 on success.
+ @rtype: integer
+ """
+ obj = self._get_object(window_name, object_name)
+ self._grab_focus(obj)
+ if obj.getRole() == pyatspi.ROLE_COMBO_BOX:
+ obj = self._get_child_object_type(obj, pyatspi.ROLE_TEXT)
+ if not obj:
+ raise LdtpServerException('Unable to get combo box children')
+
+ try:
+ texti = obj.queryEditableText()
+ except NotImplementedError:
+ raise LdtpServerException('Text cannot be entered into object.')
+
+ return int(texti.insertText(position, data.encode('utf-8'), len(data)))
+
def verifypartialmatch(self, window_name, object_name, partial_text):
"""
Verify partial text