سؤال

I am writing a javascript UI Automation testing script. How can it take screenshots of running tests?

هل كانت مفيدة؟

المحلول

In your JS code, you can take screenshots with the UIATarget methods captureScreenWithName and captureRectWithName:

captureScreenWithName

captureRectWithName

For example:

target = UIATarget.localTarget();
application = target.frontMostApp();
target.captureScreenWithName("myscreenshot");

Then, if you hit the Record button in Instruments to replay your script, when the run finishes and stops, you should find your screenshot in your test results directory.

On my system the screenshot saved after running the above example is located here:

~/Instruments/myscreenshot.png
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top