def _testProperty(self, attributeName, assertion, expected): value = pythonifyValue( getAttributeValue(self.elem, attributeName.split(".")[0])) if attributeName.endswith(".length"): value = len(value) return self._assert(value, assertion, expected)
def _delayedRender(self, request): self.deferred = None request.setHeader(b"content-type", b"application/json") results = [] r = json.loads(request.content.read().decode("utf-8")) def _filter(e): return unicode(getAttributeValue(e, "AXDOMIdentifier")) == r["id"] self.elem = findElem(self.webArea, _filter) data = r["data"] for i in xrange(len(r["data"])): assertion = data[i] if assertion[0] == "property" and assertion[1] == "accessible": results.append(self._testAccessible(*assertion[2:])) elif assertion[0] == "property" and assertion[1] == "actions": results.append(self._testActions(*assertion[2:])) elif assertion[0] == "property": results.append(self._testProperty(*assertion[1:])) elif assertion[0] == "result": results.append(self._testFunctionResult(*assertion[1:])) elif assertion[0] == "event": results.append(self._testEvent(*assertion[2:])) else: results.append({ "result": "FAIL", "message": "not implemented: %s" % assertion }) # if results[-1]["result"] == "FAIL": # print(assertion) # print(results[-1]["message"]) response = { "status": "OK", "statusText": "", "log": "", "results": results } if filter(lambda e: e["result"] != "PASS", results): url = getAttributeValue(self.webArea, "AXURL") print("=== %s" % url) for i in xrange(len(results)): if results[i]["result"] != "PASS": print("%s => %s" % (r["data"][i], results[i])) FAILURES.append({ "data": r["data"][i], "result": results[i] }) request.write(json.dumps(response, indent=4, sort_keys=True)) request.finish()
def filter(e): return getAttributeValue(e, "AXRole") == "AXWebArea"
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) while nextMarker: # elem = getParameterizedAttributeValue(root, "AXUIElementForTextMarker", nextMarker) leftWord = strFromRange(
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) endMarker = getAttributeValue(root, "AXEndTextMarker") nextMarker = getAttributeValue(root, "AXStartTextMarker") startMarker = nextMarker # markers = NSArray.alloc().initWithObjects_(nextMarker, endMarker) # r = getParameterizedAttributeValue(root, "AXTextMarkerRangeForUnorderedTextMarkers", markers) # print(strFromRange(r)) # nextMarker = getMarker(880) expected = [] words = [] elements = [] i = 0 while nextMarker: leftWord = strFromRange( getParameterizedAttributeValue(
action="store_true", help="Show immediate children only", default=False) parser.add_option("--previous", action="store_true", help="Search backwards", default=False) parser.add_option("--loop", action="store_true", help="Use loop wit start element", default=False) (options, args) = parser.parse_args() root = findElem(getRootElement(name=options.app), lambda e: getAttributeValue(e, "AXRole") == "AXWebArea") root = getAttributeValue(root, "AXChildren")[0] root = getAttributeValue(root, "AXChildren")[0] # root = getAttributeValue(root, "AXChildren")[0] # start_elem = getAttributeValue(root, "AXChildren")[0] print elementToString(root, attributes=kBasicAttributes + ["AXDOMIdentifier"]) print "===" res = [] if options.loop: r = getParameterizedAttributeValue( root, "AXUIElementsForSearchPredicate", {
def _filter(e): if getAttributeValue(e, "AXRole") != "AXWebArea": return False return True
def _filter(e): return unicode(getAttributeValue(e, "AXDOMIdentifier")) == r["id"]