I tried the tapAndHold()
function from UIAElement
var target = UIATarget.localTarget();
target.frontMostApp().mainWindow().buttons()["Button"].tapAndHold()
target.captureScreenWithName("shot")
but this fails with a JavaScript error: 'undefined' is not a function (evaluating target.frontMostApp().mainWindow().buttons()["Button"].tapAndHold()
.
Update:
I also tried
target.frontMostApp().mainWindow().buttons()["Button"].touchAndHold(1.5)
target.captureScreenWithName("shot")
which at least does highlight the button but when the screenshot is made it already is deactivated again. :(