Upload
imogene-hines
View
217
Download
0
Embed Size (px)
DESCRIPTION
Getting started with a sample
Citation preview
Visual 1: Working with Visual Analysis
2014
Agenda• Overview of the Preview Panel– Breakdown of its components and how to use
• Visual Analysis– Text and Image
• Key Parameters– Ensuring a successful search
• Working with application commands– Introduction into native application
(part of this lesson’s assignment)
Getting started with a sample
The Preview Panel1. Prompt to enter values for parameters at run-time
2. Display advanced parameters
3. Function parameters window
4. Haystack
5. Needle
6. Enable search results
7. Snapshot mode
8. Handset mode
9. Visual relationship
10. Refresh screenshot
11. Haystack zoom out
12. Haystack fit to screen
13. Haystack zoom in
14. Use screenshot as needle
15. Load needle from repository
16. Crop needle area
17. Save needle with logical name
18. Needle zoom out
19. Needle fit to screen
20. Needle zoom in
21. View Help
Working with Images
• The text commands all have an equivalent command that searches for an image as a needle
• Image can be provided from the repository or taken from the device via the Preview Panel– System expects to find an exact
match of the image– To support different screens, it is
possible to “forgive” slight changes that can result from different screens (match-mode parameter)
Click
• Clicking Button.Click(text) & Select text– Both commands search
for needle and click on it
– Button.Click(text) uses custom OCR settings per platform and is the recommended command
Commands - Edit.Set(text)
• Sets a value inside an input field
• Works by searching for a label (the needle)
• Finds the field in relation to the label
• Direction• Distance (in
percentage of screen)• Clicks on the field,
removing previous text and entering the value
Commands - Validations• Validations use same
mechanism as click commands, but do not perform any action
• Useful for making tests pass/fail(e.g. did login succeed? )
• Sync and Check– They are the same command,
sync has a default timeout of 60 seconds and check does not
– Timeout is the duration in which the system searches continually for the needle
Scrolling• In some cases the needle is not on the visible
screen and it is necessary to scroll in order to find it• The “Scroll and Search” parameter turns on this
functionality• Switched off by default• Available in all visual analysis commands• How it works:
– Needle is not found– System Performs scroll operation and then searches
again for the needle (repeated for 5 times)– Scroll cannot be used together with a positive Timeout,
because they dictate a different behavior when the needle is not found
Sleep()• Suspends test for a specified number
of milliseconds before performing the next step
• Part of the MobileCloud project template
• For example: sleep(3000);/* * Suspend test for a specified number of milliseconds. */private static void sleep(long millis) {
try {Thread.sleep(millis);
} catch (InterruptedException e) {}
Part of this lesson assignmentWorking with application commands
Application Commands
• When working on application best practice is:– Upload…– Install & Start the App at
beginning of test– Close & Uninstall at end
of test• The app identifier is the
application name
Uploading Applications• Two approaches of installing a single
application on the device1. Upload an application to the media
repository and install it.2. Install an application located in a local
file. /** Upload an application to the media repository and install it.*/String repositoryKey = "PUBLIC:PMIOSDemoInstrumented.ipa";File file = new File("C:\\test\\applications\\PMIOSDemoInstrumented.ipa");driver.uploadMedia(repositoryKey, file);device.installApplication(repositoryKey);
/** Install an application located in a local file.*/device.installApplication("C:\\test\\applications\\PMIOSDemoInstrumented.ipa");
Uploading Media
• Two approaches uploading media into the MobileCloud Repository:1. Extract the image with the
preview panel and save it with a logical name
2. Upload the image from a local file to the repository (code upload)
/** Upload a local file to the MobileCloud media repository.* If the file already exists, it will be overwritten.*/String repositoryKey = "PRIVATE:myImage.jpg";File file = new File("C:\\test\\images\\myImage.jpg");driver.uploadMedia(repositoryKey, file);
Resources• Javadoc– http://www.perfectomobile.com/javadoc/
• Sample script– https://
community.perfectomobile.com/posts/973148
• Code snippets– https://community.perfectomobile.com/s
eries/18680-mobilecloud-webdriver-code-snippets
• GitHub repository– https://github.com/perfectomobile
Thank You