Skip to content

Commit 248de3b

Browse files
� Conflicts: � requirements-linux.txt � requirements-mac.txt � requirements-win.txt � requirements.txt
2 parents 5f7807f + 9de324f commit 248de3b

8 files changed

Lines changed: 98 additions & 13 deletions

File tree

Framework/Built_In_Automation/Database/BuiltInFunctions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ def select_from_db(data_set):
451451
if "table" in left.lower():
452452
# Get the and query, and remove any whitespaces
453453
table_name= right.strip()
454-
if left.lower()=="where":
454+
if left.strip().lower()=="where":
455455
where=right.strip()
456456
if "action" in mid.lower():
457457
variable_name = right.strip()

Framework/Built_In_Automation/Mobile/CrossPlatform/Appium/BuiltInFunctions.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# -*- coding: cp1252 -*-
33

44
""" Name: Built In Functions - Appium
5-
Description: Contains all Sequential Actions related to automating Android and IOS using Appium
5+
Description: Contains all Sequential Actions related to automating Android, IOS and MacOS using Appium
66
"""
77

88
#########################
@@ -14,6 +14,7 @@
1414
from appium import webdriver
1515
from appium.options.android import UiAutomator2Options
1616
from appium.options.ios import XCUITestOptions
17+
from appium.options.mac import Mac2Options
1718
import traceback
1819
import socket
1920
import os, sys, datetime, time, inspect, subprocess, re, signal, _thread, requests, copy
@@ -341,7 +342,7 @@ def find_correct_device_on_first_run(serial_or_name, device_info):
341342

342343
@logger
343344
def unlock_android_device(data_set):
344-
""" Unlocks an androi device with adb commands"""
345+
""" Unlocks an android device with adb commands"""
345346

346347
sModuleInfo = inspect.currentframe().f_code.co_name + " : " + MODULE_NAME
347348

@@ -460,10 +461,6 @@ def launch_application(data_set):
460461

461462
# Parse data set
462463
try:
463-
desiredcaps = {}
464-
desiredcaps['unicodeKeyboard'] = False
465-
desiredcaps['resetKeyboard'] = False
466-
467464
browserstack_run = False
468465
aws_run = False
469466

@@ -494,6 +491,7 @@ def launch_application(data_set):
494491
platform_version = ""
495492
device_name = ""
496493
ios = ""
494+
macos = ""
497495
no_reset = False
498496
work_profile = False
499497

@@ -506,6 +504,8 @@ def launch_application(data_set):
506504
activity_name = right
507505
elif left in ("ios", "ios simulator") and mid == "element parameter":
508506
ios = right
507+
elif "macos" in left.lower().strip():
508+
macos = right.strip()
509509
elif left == "work profile" and right.strip().lower() in ("yes", "true"):
510510
work_profile = True
511511
elif left in ("no reset", "no_reset", "noreset") and mid == "element parameter":
@@ -521,9 +521,12 @@ def launch_application(data_set):
521521
desiredcaps['unicodeKeyboard'] = False
522522
desiredcaps['resetKeyboard'] = False
523523
# Set the global variable for the preferred connected device
524-
if find_correct_device_on_first_run(serial, device_info) in failed_tag_list:
524+
if find_correct_device_on_first_run(serial, device_info) in failed_tag_list and macos == "":
525525
return "zeuz_failed"
526-
526+
elif macos != "":
527+
device_id = "device 1"
528+
appium_details[device_id] = {"driver":None, "server":None, "serial":"", "type":"macos", "iemi":"", "platform_version":"", "device_name":""}
529+
527530
device_type = appium_details[device_id]["type"].lower().strip()
528531

529532
for left, mid, right in data_set:
@@ -593,14 +596,15 @@ def launch_application(data_set):
593596
platform_version=platform_version,
594597
device_name=device_name,
595598
ios=ios,
599+
macos = macos,
596600
no_reset=no_reset,
597601
work_profile=work_profile,
598602
desiredcaps=desiredcaps,
599603
)
600604
if result == "zeuz_failed":
601605
return "zeuz_failed"
602606

603-
if launch_app: # if ios simulator then no need to launch app again
607+
if launch_app and macos == "": # if ios simulator then no need to launch app again
604608
appium_driver.activate_app(package_name) # Launch program configured in the Appium capabilities
605609
CommonUtil.ExecLog(sModuleInfo, "Launched the application successfully.", 1)
606610
return "passed"
@@ -761,6 +765,7 @@ def start_appium_driver(
761765
platform_version="",
762766
device_name="",
763767
ios="",
768+
macos="",
764769
no_reset=False,
765770
work_profile=False,
766771
desiredcaps=None,
@@ -916,6 +921,13 @@ def start_appium_driver(
916921
desired_caps["deviceName"] = "iPhone" # Read model (only needs to be unique if using more than one)
917922
desired_caps["bundleId"] = ios
918923
desired_caps["udid"] = appium_details[device_id]["serial"] # Device unique identifier - use auto if using only one phone
924+
elif str(appium_details[device_id]["type"]).lower() == "macos":
925+
CommonUtil.ExecLog(sModuleInfo, "Setting up with MacOS", 1)
926+
desired_caps["platformName"] = "mac"
927+
desired_caps["automationName"] = "mac2"
928+
desired_caps["wdaLocalPort"] = wdaLocalPort
929+
desired_caps["bundleId"] = macos
930+
desired_caps["newCommandTimeout"] = 6000
919931
else:
920932
CommonUtil.ExecLog(sModuleInfo, "Invalid device type: %s" % str(appium_details[device_id]["type"]), 3)
921933
return "zeuz_failed", launch_app
@@ -942,6 +954,8 @@ def start_appium_driver(
942954

943955
if appium_driver: # Make sure we get the instance
944956
appium_details[device_id]["driver"] = appium_driver
957+
if appium_details[device_id]["type"] == "macos":
958+
Shared_Resources.Set_Shared_Variables("screen_capture", "desktop")
945959
Shared_Resources.Set_Shared_Variables("appium_details", appium_details)
946960
CommonUtil.set_screenshot_vars(Shared_Resources.Shared_Variable_Export())
947961
CommonUtil.ExecLog(sModuleInfo, "Appium driver created successfully.", 1)

Framework/Built_In_Automation/Sequential_Actions/action_declarations/common.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@
125125

126126
{"name": "connect to bigquery client", "function": "connect_to_bigquery_client", "screenshot": "none" },
127127
{"name": "execute bigquery query", "function": "execute_bigquery_query", "screenshot": "none" },
128+
129+
{"name": "connect to google service client", "function": "connect_to_google_service_account", "screenshot": "none" },
130+
{"name": "upload to google storage bucket", "function": "upload_to_google_storage_bucket", "screenshot": "none" },
128131

129132
) # yapf: disable
130133

Framework/Built_In_Automation/Sequential_Actions/common_functions.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6505,6 +6505,70 @@ def execute_bigquery_query(data_set):
65056505
except:
65066506
return CommonUtil.Exception_Handler(sys.exc_info())
65076507

6508+
@logger
6509+
def connect_to_google_service_account(data_set):
6510+
"""
6511+
data_set:
6512+
credentials path | input parameter | path to credentails json file
6513+
connect to google service client | common action | client variable name
6514+
"""
6515+
6516+
sModuleInfo = inspect.currentframe().f_code.co_name + " : " + MODULE_NAME
6517+
CommonUtil.ExecLog(sModuleInfo, "Actions involving the Google service account may not function correctly without a virtual environment.", 2)
6518+
cred_path = None
6519+
client_var_name = None
6520+
for left, _, right in data_set:
6521+
if left.strip().lower() == 'credentials path':
6522+
cred_path = right.strip()
6523+
if left.strip().lower() == 'connect to google service client':
6524+
client_var_name = right.strip()
6525+
6526+
try:
6527+
from google.cloud import storage
6528+
client = storage.Client.from_service_account_json(json_credentials_path=cred_path)
6529+
sr.Set_Shared_Variables(client_var_name, client)
6530+
return "passed"
6531+
except:
6532+
CommonUtil.ExecLog(sModuleInfo, "Incorrect Credentails", 3)
6533+
return "zeuz_failed"
6534+
6535+
@logger
6536+
def upload_to_google_storage_bucket(data_set):
6537+
"""
6538+
data_set:
6539+
filepath | input parameter | filepath
6540+
bucket | input parameter | bucket name
6541+
upload to google storage bucket | common action | client variable name
6542+
"""
6543+
6544+
sModuleInfo = inspect.currentframe().f_code.co_name + " : " + MODULE_NAME
6545+
CommonUtil.ExecLog(sModuleInfo, "Actions involving the Google service account may not function correctly without a virtual environment.", 2)
6546+
filepath = None
6547+
client_var_name = None
6548+
bucket = None
6549+
6550+
for left, _, right in data_set:
6551+
if left.strip().lower() == 'filepath':
6552+
filepath = right.strip()
6553+
if left.strip().lower() == 'upload to google storage bucket':
6554+
client_var_name = right.strip()
6555+
if left.strip().lower() == 'bucket':
6556+
bucket = right.strip()
6557+
6558+
if None in (filepath,client_var_name,bucket):
6559+
CommonUtil.ExecLog(sModuleInfo, "Incorrect Dataset", 3)
6560+
return "zeuz_failed"
6561+
6562+
try:
6563+
client = sr.Get_Shared_Variables(client_var_name)
6564+
bucket = client.get_bucket(bucket)
6565+
blob = bucket.blob(os.path.basename(filepath))
6566+
blob.upload_from_filename(filepath)
6567+
CommonUtil.ExecLog(sModuleInfo, f'File {filepath} uploaded to {bucket}.')
6568+
return "passed"
6569+
except:
6570+
return CommonUtil.Exception_Handler(sys.exc_info())
6571+
65086572
@logger
65096573
def text_to_speech(data_set):
65106574
"""

requirements-linux.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,5 @@ pandas
5757
pyperclip
5858
thefuzz
5959
backports-datetime-fromisoformat; python_version < '3.11'
60-
genson
60+
genson
61+
google-cloud-storage

requirements-mac.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,5 @@ pandas
6161
pyperclip
6262
backports-datetime-fromisoformat; python_version < '3.11'
6363
thefuzz
64-
genson
64+
genson
65+
google-cloud-storage

requirements-win.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,4 @@ pyperclip
7272
backports-datetime-fromisoformat; python_version < '3.11'
7373
thefuzz
7474
genson
75+
google-cloud-storage

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,5 @@ boto3
5252
pandas
5353
pyperclip
5454
backports-datetime-fromisoformat; python_version < '3.11'
55-
genson
55+
genson
56+
google-cloud-storage

0 commit comments

Comments
 (0)