Skip to content

Conversation

@zahin178
Copy link
Contributor

@zahin178 zahin178 commented Aug 17, 2023

PR Type

Feature

PR Checklist

  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.
  • A changelog entry has been made.
  • Version number has been updated.
  • Required modules have been added to respective "requirements*.txt" files.
  • Relevant Test Cases added to this description (below).
  • (Team) Label with affected action categories and semver status.

Overview

Have added two new functions in Framework\Built_In_Automation\Mobile\CrossPlatform\Appium\BuiltInFunctions.py the functions are zoom_action and pan_action

The zoom_action function will enable zoom in and zoom out for Android devices

The pan_action function will pan left/right/up/down for Android devices

Also have updated the take_screenshot_appium function. Previously the screenshot's name was saved as a timestamp of the moment the screenshot was taken. But now we can provide a name as an optional option parameter. We can also access the location of the screen_capture_folder by providing a variable name in appium action. The default variable is 'ss_path'

filename = None
    var_name = 'ss_path'

for left, mid, right in data_set:
        if left.strip().lower() == 'filename':
            filename = right.strip().lower()
        elif 'action' in mid.strip().lower():
            var_name = right.strip()

if filename == None:
        filename_format = "%Y_%m_%d_%H-%M-%S"
        filename = time.strftime(filename_format) + ".png"
Shared_Resources.Set_Shared_Variables(var_name, screenshot_folder)

Also updated the compare_images function. The 'skimage' library will only get installed if we call the compare_images function. Also we can access the score of similarity by using the 'score' variable. We can also set the variable name in 'utility action' row

 try:
        import skimage, cv2, imutils
        from skimage.metrics import structural_similarity as ssim
 except:
        from Framework.module_installer import install_missing_modules
        install_missing_modules(['scikit-image'])
        import skimage, cv2, imutils
        from skimage.metrics import structural_similarity as ssim

Test Cases

@Muntasib-creator Muntasib-creator changed the title Add zoom and pan [wip] Add zoom and pan Aug 19, 2023
try:
for left, mid, right in data_set:
if left.strip().lower() == 'action':
action = right.strip().lower().replace(' ','')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strip() not required

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the strip() not required? Is it because the word "Action" will come from the control server and as there will be no user interference hence no need to strip() the word?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace() function you wrote is already doring strip()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

elif left.strip().lower() == 'count':
count = int(right)
elif 'coordinates' in left.strip().lower():
cords = right.strip()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you tested this code? I dont think it will work

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I haven't tested it. In fact, we can remove this part. The idea was the user could provide a (x,y) coordinate and the zoom/pan action would occur keeping that coordinate in the center. But now as we have added element parameter I think it's redundant to keep the option of the coordinates as well. What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay. since there is no client need as well, you can remove it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

x_cord2 = int(cords[1].replace(')',''))
elif left.strip().lower() == 'double tap':
if right.strip().lower() == 'true':
double_tap = True
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double_tap = right.strip().lower() in ('true', 'enable', 'ok', 'yes')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@sazid sazid merged commit 2bafbf3 into dev Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants