Skip to content

Commit b853b1a

Browse files
Merge branch 'dev' of https://github.com/AutomationSolutionz/Zeuz_Python_Node into image_search_easyocr_one
# Conflicts: # Framework/Built_In_Automation/Desktop/Windows/BuiltInFunctions.py
2 parents 4e60b03 + cef4ce5 commit b853b1a

31 files changed

Lines changed: 1919 additions & 153 deletions

.vscode/settings.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
{
22
"python.linting.enabled": true,
33
"python.formatting.provider": "yapf",
4-
"python.analysis.typeCheckingMode": "basic"
4+
"python.analysis.typeCheckingMode": "basic",
5+
"files.readonlyInclude": {
6+
"**/.git": true,
7+
"**/node_modules": true,
8+
"Framework/settings.conf": true,
9+
"node_state.json": true,
10+
"pid.txt": true
11+
}
512
}

Batch_Files/edit_node_id.bat

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
@echo off
2+
title Edit Node ID
3+
set "conf_file=node_id.conf"
4+
for /f "delims=" %%i in ('dir /b /s "%conf_file%"') do set "file_dir=%%~dpi"
5+
cd /d "%file_dir%"
6+
7+
set "key_to_modify=id "
8+
for /f "tokens=1,* delims==" %%a in ('type "%conf_file%"') do (
9+
if "%%a"=="%key_to_modify%" (
10+
echo Current Node ID: %%b
11+
))
12+
:loop
13+
set /p new_value= Enter New Node ID (Letters, Digits and "-" Only):
14+
echo %new_value%| findstr /R "^[A-Za-z0-9\-]*$">nul
15+
if errorlevel 1 (
16+
echo Invalid input. Please try again.
17+
) else (
18+
goto endloop
19+
)
20+
goto loop
21+
22+
:endloop
23+
(for /f "tokens=1,* delims==" %%a in ('type "%conf_file%"') do (
24+
if "%%a"=="%key_to_modify%" (
25+
echo %key_to_modify%= %new_value%
26+
) else (
27+
echo %%a
28+
)
29+
)) > "%conf_file%.tmp"
30+
31+
move /y "%conf_file%.tmp" "%conf_file%" > nul
32+
33+
for /f "tokens=1,* delims==" %%a in ('type "%conf_file%"') do (
34+
if "%%a"=="%key_to_modify%" (
35+
echo New Node ID: %%b
36+
))
37+
pause

Batch_Files/logout.bat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
for /f "tokens=2 delims=," %%a in ('tasklist /nh /fi "imagename eq Python.exe" /fo csv') do set pid=%%~a
3+
taskkill /PID %pid% /F /T

Batch_Files/server_login.bat

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@echo off
2+
title Login
3+
set file=node_cli.py
4+
for /f "delims=" %%i in ('dir /b /s "node_cli.py"') do set "file_dir=%%~dpi"
5+
cd /d "%file_dir%"
6+
python "%file%" -l
7+

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
# Version 16
55

66
### [Current changes]
7+
- **[Add]** Connect and Run Query on BigQuery
8+
- **[Add]** Page load timeout
9+
- **[Add]** New "Rust" based performance action.
10+
- **[Add]** Added - Text to Speech action
11+
- **[Add]** Added - S3 Actions
12+
- **[Fix]** Fix chrome. firefox & edge driver issues on selenium 4.10 (executable_path error).
13+
- **[Add]** Browserstack - WEB support
714
- **[Add]** Added - Convert XML to JSON format
815
- **[Add]** Added - sbl flag to enable showing browser log in console. Default: False
916
- **[Add]** Resize selenium window action

Framework/Built_In_Automation/Desktop/Windows/BuiltInFunctions.py

Lines changed: 92 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
import PIL
3434
from PIL import Image, ImageGrab
3535

36-
import psutil
37-
3836

3937
python_folder = []
4038
for location in subprocess.getoutput("where python").split("\n"):
@@ -44,13 +42,18 @@
4442
python_location = "" if len(python_folder) == 0 else "by going to {}".format(python_folder[0].split("Python")[0] + "Python")
4543
except:
4644
python_location = ""
47-
if not 3.5 <= float(sys.version.split(" ")[0][0:3]) <= 3.8:
45+
46+
full_python_version = sys.version.split(" ")[0]
47+
python_sub_version = re.search(r'\b\d+\.(\d+)\.\d+\b', full_python_version)
48+
49+
if not 7 <= int(python_sub_version.group(1)) <= 11:
4850
error_msg = "You have the wrong Python version or bit" \
51+
+"\nThe Python version should be 3.7 <= x <= 3.11"\
4952
+ "\nFollow this procedure" \
5053
+ "\n1.Go to settings, then go to Apps and in search box type python and uninstall all python related things" \
5154
+ "\n2.Delete your Python folder" \
5255
+ python_location \
53-
+ "\n3.Go to this link and download python https://www.python.org/ftp/python/3.8.10/python-3.8.10-amd64.exe" \
56+
+ "\n3.Go to this link and download python https://www.python.org/ftp/python/3.11.4/python-3.11.4-amd64.exe" \
5457
+ "\n4.During installation, give uncheck 'for all user' and check 'Add Python to Path'. This is very important." \
5558
+ "\n5.Relaunch zeuz node_cli.py"
5659
CommonUtil.ExecLog("", error_msg, 3)
@@ -995,6 +998,90 @@ def install_ocr():
995998
def image_search(step_data_set):
996999
install_ocr()
9971000
sModuleInfo = inspect.currentframe().f_code.co_name + " : " + MODULE_NAME
1001+
1002+
try:
1003+
# steps to install the pytesseract module
1004+
pip_command = ['pip', 'list']
1005+
pytesseract_search_command = ['findstr', 'pytesseract']
1006+
1007+
pip_process = subprocess.Popen(pip_command, stdout=subprocess.PIPE)
1008+
search_process = subprocess.Popen(pytesseract_search_command, stdin=pip_process.stdout, stdout=subprocess.PIPE, text=True)
1009+
1010+
is_pytesseract,_ = search_process.communicate()
1011+
1012+
if is_pytesseract:
1013+
CommonUtil.ExecLog(
1014+
sModuleInfo,
1015+
"Pytesseractt is already installed",
1016+
5,
1017+
)
1018+
else:
1019+
CommonUtil.ExecLog(
1020+
sModuleInfo,
1021+
"Installing Pytesseract",
1022+
5,
1023+
)
1024+
os.system('echo y | pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org pytesseract')
1025+
except:
1026+
CommonUtil.ExecLog(
1027+
sModuleInfo,
1028+
"Could not install the Pytesseract module",
1029+
3,
1030+
)
1031+
1032+
try:
1033+
# steps to install pytesseract executable file
1034+
reg_query_cmd = ['reg', 'query', r'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', '/s']
1035+
findstr_cmd = ['findstr', '/B', '.*DisplayName']
1036+
tesseract_cmd = ['findstr', 'Tesseract-OCR']
1037+
1038+
reg_query_process = subprocess.Popen(reg_query_cmd, stdout=subprocess.PIPE)
1039+
findstr_process = subprocess.Popen(findstr_cmd, stdin=reg_query_process.stdout, stdout=subprocess.PIPE)
1040+
tesseract_process = subprocess.Popen(tesseract_cmd, stdin=findstr_process.stdout, stdout=subprocess.PIPE, text=True)
1041+
1042+
is_pytesseract_exe, _ = tesseract_process.communicate()
1043+
1044+
if is_pytesseract_exe:
1045+
CommonUtil.ExecLog(
1046+
sModuleInfo,
1047+
"Pytesseract executable file is alreday installed",
1048+
5,
1049+
)
1050+
else:
1051+
CommonUtil.ExecLog(
1052+
sModuleInfo,
1053+
"Starting installation of Pytesseract executable file",
1054+
5,
1055+
)
1056+
install_process = subprocess.Popen(['winget', 'install', 'Tesseract-OCR - open source OCR engine'], text=True)
1057+
stdout, stderr = install_process.communicate()
1058+
if stdout is not None:
1059+
CommonUtil.ExecLog(sModuleInfo, f"The standard output for winget install Tesseract-OCR {stdout}", 5)
1060+
if stderr is not None:
1061+
CommonUtil.ExecLog(
1062+
sModuleInfo,
1063+
f"The standard error for winget install Tesseract-OCR {stderr}",
1064+
5,
1065+
)
1066+
else:
1067+
CommonUtil.ExecLog(sModuleInfo, f"Tesseract installation is complete!", 5)
1068+
1069+
CommonUtil.ExecLog(
1070+
sModuleInfo,
1071+
"Setting up the environment variable for Tesseract OCR",
1072+
5,
1073+
)
1074+
1075+
# Todo: No need to add this in PATH
1076+
ocr_path = r"C:\Program Files\Tesseract-OCR"
1077+
os.environ['PATH'] += ';' + ocr_path
1078+
except:
1079+
CommonUtil.ExecLog(
1080+
sModuleInfo,
1081+
"Could not install the Pytesseract executable file",
1082+
3,
1083+
)
1084+
9981085
try:
9991086
file_name = ""
10001087
resolution = ""
@@ -2159,7 +2246,7 @@ def Keystroke_For_Element(data_set):
21592246
keystroke_value = right.strip().lower() # Store keystroke
21602247
elif left == "keystroke chars":
21612248
keystroke_char = right
2162-
if "parameter"in mid.lower():
2249+
if "optional parameter"in mid.lower():
21632250
if left == "method":
21642251
method_name= right.lower()
21652252

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ def launch_application(data_set):
526526

527527
for left, mid, right in data_set:
528528
left, mid = left.strip().lower(), mid.strip().lower()
529-
if "parameter" in mid and "=" in right:
529+
if "optional parameter" in mid and "=" in right:
530530
# key, value
531531
k, v = map(lambda x: x.strip(), right.split("="))
532532
if left in (device_type, "multi"):
@@ -2025,7 +2025,7 @@ def Click_Element_Appium(data_set):
20252025
for left, mid, right in data_set:
20262026
left = left.lower().strip()
20272027
mid = mid.lower().strip()
2028-
if mid in ("option", "parameter") and "x_offset:y_offset" in left:
2028+
if mid in ("option", "optional parameter") and "x_offset:y_offset" in left:
20292029
offset = True
20302030
x_offset, y_offset = [i.strip() for i in (right.strip()).split(":")]
20312031

@@ -3067,14 +3067,14 @@ def Validate_Text_Appium(data_set):
30673067
try:
30683068
for each_step_data_item in data_set[0]:
30693069
if (
3070-
"parameter" in each_step_data_item[1]
3070+
"optional parameter" in each_step_data_item[1]
30713071
or each_step_data_item[1] == "element parameter"
30723072
) and each_step_data_item[2] == "":
30733073
Element = appium_driver.find_elements_by_xpath(
30743074
"//*[@%s]" % each_step_data_item[0]
30753075
)
30763076
if (
3077-
"parameter" in each_step_data_item[1]
3077+
"optional parameter" in each_step_data_item[1]
30783078
or each_step_data_item[1] == "element parameter"
30793079
) and each_step_data_item[2] != "":
30803080
Element = LocateElement.Get_Element(data_set[0], appium_driver)

Framework/Built_In_Automation/Performance_Testing/BuiltInFunctions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def assign_locust_task(data_set):
238238
taskset_name = right.strip()
239239
elif "task name" == left:
240240
task_name = right.strip().lower()
241-
if mid.strip().lower() == "parameter":
241+
if mid.strip().lower() == "optional parameter":
242242
if "weight" == left.strip():
243243
weight = right.strip().lower()
244244
elif mid.strip().lower() == "action":

Framework/Built_In_Automation/Sequential_Actions/action_declarations/common.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,16 @@
111111
{"name": "xml to json", "function": "xml_to_json", "screenshot": "none" },
112112

113113
# AI actions
114-
{"name": "classifier ai", "function": "classifier_AI", "screenshot": "none" },
114+
{"name": "classifier ai", "function": "classifier_AI", "screenshot": "none" },
115115

116+
{"name": "connect to S3", "function": "connect_to_S3", "screenshot": "none" },
117+
{"name": "upload to S3", "function": "upload_to_S3", "screenshot": "none" },
118+
119+
{"name": "text to speech", "function": "text_to_speech", "screenshot": "none" },
120+
121+
{"name": "connect to bigquery client", "function": "connect_to_bigquery_client", "screenshot": "none" },
122+
{"name": "execute bigquery query", "function": "execute_bigquery_query", "screenshot": "none" },
123+
116124
) # yapf: disable
117125

118126
module_name = "common"

Framework/Built_In_Automation/Sequential_Actions/action_declarations/selenium.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
{ "name": "slider bar", "function": "slider_bar", "screenshot": "web" },
6262
{ "name": "get performance metrics", "function": "get_performance_metrics", "screenshot": "web" },
6363
{ "name": "resize window", "function": "resize_window", "screenshot": "web" },
64+
{ "name": "change attribute value", "function": "Change_Attribute_Value", "screenshot": "web" },
6465
) # yapf: disable
6566

6667
module_name = "selenium"

0 commit comments

Comments
 (0)