Esempio n. 1
0
    def _getWebArea(self):
        def _filter(e):
            if getAttributeValue(e, "AXRole") != "AXWebArea":
                return False
            return True

        rootElem = getRootElement(name=self.appName)
        return findElem(rootElem, _filter)
Esempio n. 2
0

if __name__ == "__main__":
    from optparse import OptionParser
    parser = OptionParser()
    parser.add_option("--app",
                      action="store",
                      type="string",
                      help="Target app",
                      default="Nightly")
    (options, args) = parser.parse_args()

    def filter(e):
        return getAttributeValue(e, "AXRole") == "AXWebArea"

    root = findElem(getRootElement(name=options.app), filter)

    # print(root)
    endMarker = getAttributeValue(root, "AXEndTextMarker")
    nextMarker = getAttributeValue(root, "AXStartTextMarker")
    startMarker = nextMarker
    # print(nextMarker)

    # markers = NSArray.alloc().initWithObjects_(nextMarker, endMarker)
    # r = getParameterizedAttributeValue(root, "AXTextMarkerRangeForUnorderedTextMarkers", markers)
    # print(strFromRange(r))

    # nextMarker = getMarker(880)
    i = 0
    # nextMarker = getParameterizedAttributeValue(root, "AXNextTextMarkerForTextMarker", nextMarker)
Esempio n. 3
0
                      action="append",
                      default=[],
                      help="Show provided attributes")
    parser.add_option("-w",
                      "--web",
                      action="store_true",
                      help="Only output web area subtree",
                      default=False)
    parser.add_option("--actions",
                      action="store_true",
                      help="Show actions",
                      default=False)
    parser.add_option("--list-attributes",
                      action="store_true",
                      help="List attributes",
                      default=False)
    parser.add_option("--list-param-attributes",
                      action="store_true",
                      help="List parameterized attributes",
                      default=False)
    (options, args) = parser.parse_args()

    root = getRootElement(name=options.app)
    if options.web:
        root = findWebArea(root)

    if root:
        dumpTree(root, kBasicAttributes + options.attribute, options.actions,
                 options.list_attributes, options.list_param_attributes)
    else:
        print "no root"
Esempio n. 4
0
from common import getRootElement, findWebArea, elementToString, \
  getAttributeValue, getParameterizedAttributeValue, \
  findElemWithDOMIdentifier
from Foundation import NSDictionary, NSArray

root = findElemWithDOMIdentifier(getRootElement(name="Safari"), "image_1")
print(elementToString(root))
startMarker = getAttributeValue(root, "AXStartTextMarker")
endMarker = getAttributeValue(root, "AXEndTextMarker")
markers = NSArray.alloc().initWithObjects_(startMarker, endMarker)
r = getParameterizedAttributeValue(root,
                                   "AXTextMarkerRangeForUnorderedTextMarkers",
                                   markers)


def strFromRange(r):
    return getParameterizedAttributeValue(root, "AXStringForTextMarkerRange",
                                          r)


print(len(strFromRange(r)))

# nextMarker = startMarker
# index = 0
# while True:
#   nextMarker = getParameterizedAttributeValue(root, "AXNextTextMarkerForTextMarker", nextMarker)
#   leftWord = strFromRange(getParameterizedAttributeValue(root, "AXLeftWordTextMarkerRangeForTextMarker", nextMarker))
#   rightWord = strFromRange(getParameterizedAttributeValue(root, "AXRightWordTextMarkerRangeForTextMarker", nextMarker))
#   print("%d [%s] [%s] " % (index, leftWord, rightWord))
#   index += 1
#   if not nextMarker or nextMarker == endMarker: