Skip to content

Commit 56220e9

Browse files
Merge pull request #466 from AutomationSolutionz/minor
Minor
2 parents 19b536b + b1d7ac8 commit 56220e9

9 files changed

Lines changed: 96 additions & 24 deletions

File tree

Apps/Web/AI_Recorder_2/dist/background/back_reocrder.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ async function fetchAIData(id, command, value, url, document){
9595
validate_full_text_by_ai = true;
9696
}
9797

98+
document = document.replace(/[^\x00-\x7F]/g, '');
99+
document = document.replace(/[\x00-\x1F\x7F]/g, ''); // Optionally remove control characters (0-31 and 127 in ASCII)
98100
var dataj = {
99101
"page_src": document,
100102
"action_name": command,
@@ -115,6 +117,10 @@ async function fetchAIData(id, command, value, url, document){
115117
}
116118
var r = await fetch(url_, input)
117119
var resp = await r.json();
120+
if (resp.info !== 'success'){
121+
console.error('resp', resp.info)
122+
return
123+
}
118124
let response = resp.ai_choices;
119125

120126
if (validate_full_text_by_ai){

Apps/Web/AI_Recorder_2/public/background/back_reocrder.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ async function fetchAIData(id, command, value, url, document){
9595
validate_full_text_by_ai = true;
9696
}
9797

98+
document = document.replace(/[^\x00-\x7F]/g, '');
99+
document = document.replace(/[\x00-\x1F\x7F]/g, ''); // Optionally remove control characters (0-31 and 127 in ASCII)
98100
var dataj = {
99101
"page_src": document,
100102
"action_name": command,
@@ -115,6 +117,10 @@ async function fetchAIData(id, command, value, url, document){
115117
}
116118
var r = await fetch(url_, input)
117119
var resp = await r.json();
120+
if (resp.info !== 'success'){
121+
console.error('resp', resp.info)
122+
return
123+
}
118124
let response = resp.ai_choices;
119125

120126
if (validate_full_text_by_ai){

Apps/Web/aiplugin/inspect.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ class Inspector {
143143

144144
// send data to zeuz server directly
145145

146+
refinedHtml = refinedHtml.replace(/[^\x00-\x7F]/g, '');
147+
refinedHtml = refinedHtml.replace(/[\x00-\x1F\x7F]/g, '');
146148
var data = JSON.stringify({
147149
"page_src": refinedHtml,
148150
"action_type": "selenium"
@@ -212,6 +214,8 @@ class Inspector {
212214

213215
// send data to zeuz server directly
214216

217+
refinedHtml = refinedHtml.replace(/[^\x00-\x7F]/g, '');
218+
refinedHtml = refinedHtml.replace(/[\x00-\x1F\x7F]/g, '');
215219
var data = JSON.stringify({
216220
"page_src": refinedHtml,
217221
"action_type": "selenium"

Apps/Windows/ZeuZ_Windows_Inspector.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,10 @@ def Upload(auth_thread, window_name):
131131

132132
r = requests.request("POST", url, headers=headers, data=content, verify=False)
133133
response = r.json()
134-
del response["content"]
135-
r.ok and print("Content successfully sent to AI Engine\n")
134+
if response["info"] == "success":
135+
r.ok and print("Content successfully sent to AI Engine\n")
136+
else:
137+
ExecLog("", response["info"], 3)
136138
except:
137139
Exception_Handler(sys.exc_info())
138140
ExecLog("", "Could not upload Element identifiers xml", 3)

Framework/Built_In_Automation/Sequential_Actions/action_declarations/common.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,13 @@
9090
{"name":"download attachment from global", "function": "download_attachment_from_global", "screenshot": "none" },
9191

9292
# data-store actions
93-
{"name": "data store: read", "function": "data_store_read", "screenshot": "none"},
94-
{"name": "data store: get data", "function": "data_store_get_data", "screenshot": "none"},
95-
{"name": "data store: stats", "function": "data_store_get_stats", "screenshot": "none"},
96-
{"name": "data store: write", "function": "data_store_write", "screenshot": "none"},
97-
{"name": "data store: insert", "function": "data_store_insert", "screenshot": "none"},
98-
{"name": "data store: insert column", "function": "data_store_insert_column", "screenshot": "none"},
93+
{"name": "data store: read", "function": "data_store_read", "screenshot": "none"},
94+
{"name": "data store: get data", "function": "data_store_get_data", "screenshot": "none"},
95+
{"name": "data store: stats", "function": "data_store_get_stats", "screenshot": "none"},
96+
{"name": "data store: write", "function": "data_store_write", "screenshot": "none"},
97+
{"name": "data store: overwrite", "function": "data_store_overwrite", "screenshot": "none"},
98+
{"name": "data store: insert", "function": "data_store_insert", "screenshot": "none"},
99+
{"name": "data store: insert column", "function": "data_store_insert_column", "screenshot": "none"},
99100

100101

101102
# Client specific actions

Framework/Built_In_Automation/Sequential_Actions/common_functions.py

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6056,7 +6056,7 @@ def data_store_write(data_set):
60566056
temp = [right.strip()]
60576057
print(temp)
60586058
for t in temp:
6059-
tt=t.split('=')
6059+
tt = t.split('=', 1)
60606060
print(tt)
60616061
data[tt[0].strip()]=tt[1].strip()
60626062
print(data[tt[0].strip()])
@@ -6077,7 +6077,7 @@ def data_store_write(data_set):
60776077
#
60786078

60796079
# print(res.text)
6080-
if res.status_code==200:
6080+
if res.status_code == 200:
60816081
# CommonUtil.ExecLog(sModuleInfo, f"Captured following output:\n{res.text}", 1)
60826082

60836083
return sr.Set_Shared_Variables(var_name, json.loads(res.text),pretty=True)
@@ -6089,6 +6089,56 @@ def data_store_write(data_set):
60896089
return CommonUtil.Exception_Handler(sys.exc_info())
60906090

60916091

6092+
def data_store_overwrite(data_set):
6093+
"""
6094+
This function overwrites on existing data. So be careful.
6095+
Just provide raw list of list of strings.
6096+
Args:
6097+
data_set:
6098+
------------------------------------------------------------------------------
6099+
table name | input parameter | table_name
6100+
data | input parameter | [[str, str, ...] , [...], .... ]
6101+
data store: overwrite | common action | response_var
6102+
------------------------------------------------------------------------------
6103+
"""
6104+
6105+
sModuleInfo = inspect.currentframe().f_code.co_name + " : " + MODULE_NAME
6106+
6107+
try:
6108+
table_id = var_name = data = None
6109+
for left, mid, right in data_set:
6110+
left = left.strip().lower()
6111+
if left == "table id":
6112+
table_id = right.strip()
6113+
if left == "data":
6114+
data = CommonUtil.parse_value_into_object(right.strip())
6115+
if left == "data store: overwrite":
6116+
var_name = right.strip()
6117+
6118+
if None in (table_id, data, var_name):
6119+
CommonUtil.ExecLog(sModuleInfo, "table id, data and var_name is required", 3)
6120+
return "zeuz_failed"
6121+
6122+
data_adjusted = [[[str(row_i), str(col_i), cell] for col_i, cell in enumerate(row)] for row_i, row in enumerate(data)]
6123+
headers = RequestFormatter.add_api_key_to_headers({})
6124+
res = requests.post(
6125+
RequestFormatter.form_uri(f"data_store/update_datastore/{table_id}"),
6126+
data={
6127+
'data': json.dumps(data_adjusted)
6128+
},
6129+
verify=False,
6130+
**headers
6131+
)
6132+
if res.status_code == 200:
6133+
return sr.Set_Shared_Variables(var_name, res.json())
6134+
else:
6135+
CommonUtil.ExecLog(sModuleInfo, "No data found to update , please check your dataset", 1)
6136+
return "passed"
6137+
6138+
except Exception:
6139+
return CommonUtil.Exception_Handler(sys.exc_info())
6140+
6141+
60926142

60936143
def data_store_insert(data_set):
60946144
"""
@@ -6112,14 +6162,12 @@ def data_store_insert(data_set):
61126162
table_name = columns = var_name = ""
61136163
params = {}
61146164
for left, mid, right in data_set:
6115-
if left.strip() == 'table name':
6165+
if left.strip().lower() == 'table name':
61166166
table_name = right.strip()
61176167
params['table_name'] = table_name
6118-
if left.strip() == 'data':
6119-
l = ast.literal_eval(right.strip())
6168+
if left.strip().lower() == 'data':
6169+
l = CommonUtil.parse_value_into_object(right.strip())
61206170

6121-
if mid.strip() == "action":
6122-
var_name = right.strip()
61236171
data={
61246172
'table_name':table_name,
61256173
'data_list':l
@@ -6134,7 +6182,7 @@ def data_store_insert(data_set):
61346182
verify=False,
61356183
**headers
61366184
)
6137-
if res.status_code==201:
6185+
if res.status_code == 201:
61386186
CommonUtil.ExecLog(sModuleInfo, "data inserted successfully", 1)
61396187
return "passed"
61406188
# return sr.Set_Shared_Variables(var_name, json.loads(res.text),pretty=True)

Framework/MainDriverApi.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import time
88
import sys
99
from typing import Any, Dict
10+
from urllib.parse import urlparse
1011
import urllib.request, urllib.error, urllib.parse
1112
import queue
1213
import shutil
@@ -599,7 +600,7 @@ def run_all_test_steps_in_a_test_case(
599600
sTestStepStartTime = datetime.fromtimestamp(TestStepStartTime, tz=pytz.UTC).strftime("%Y-%m-%d %H:%M:%S.%f")
600601
WinMemBegin = CommonUtil.PhysicalAvailableMemory() # get available memory
601602

602-
if StepSeq in CommonUtil.disabled_step:
603+
if StepSeq in CommonUtil.disabled_step or not all_step_info[StepSeq - 1]['step_enable']:
603604
CommonUtil.ExecLog(sModuleInfo, "STEP-%s is disabled" % StepSeq, 2)
604605
sStepResult = "skipped"
605606
else:
@@ -823,7 +824,8 @@ def set_important_variables():
823824
shared.shared_variables.update({
824825
"clipboard_paste": pyperclip.paste,
825826
"clipboard_set": pyperclip.copy,
826-
"num": advanced_float
827+
"num": advanced_float,
828+
"urlparse": urlparse,
827829
})
828830

829831
except:

Framework/deploy_handler/adapter.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def read_steps(steps_pb) -> List[Dict]:
5050
"automatablity": step["stepInfo"]["stepType"],
5151
"always_run": step["stepInfo"]["alwaysRun"],
5252
"run_on_fail": step["stepInfo"]["runOnFail"],
53+
"step_enable": step["stepInfo"]["stepEnable"],
5354
"step_function": "Sequential Actions",
5455
"step_driver": step["stepInfo"]["driver"],
5556
"type": step["type"],

node_cli.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -422,10 +422,6 @@ def update_machine_info(node_id, should_print=True):
422422

423423
def RunProcess(node_id, run_once=False, log_dir=None):
424424
try:
425-
PreProcess(log_dir=log_dir)
426-
427-
save_path = Path(ConfigModule.get_config_value("sectionOne", "temp_run_file_path", temp_ini_file))
428-
429425
# --- START websocket service connections --- #
430426

431427
server_url = urlparse(ConfigModule.get_config_value("Authentication", "server_address"))
@@ -450,10 +446,15 @@ def RunProcess(node_id, run_once=False, log_dir=None):
450446
node_json = None
451447
def response_callback(response: str):
452448
nonlocal node_json
453-
nonlocal save_path
454-
save_path.mkdir(exist_ok=True, parents=True)
449+
nonlocal log_dir
450+
if log_dir is None:
451+
log_dir = temp_ini_file.parent
452+
save_path = Path(log_dir)
455453
if not save_path.exists():
456454
print(f"Folder created: {save_path}")
455+
save_path.mkdir(exist_ok=True, parents=True)
456+
PreProcess(log_dir=log_dir)
457+
457458
try:
458459
with open(save_path / "deploy-response.txt", "w", encoding="utf-8") as f:
459460
f.write(response)
@@ -561,6 +562,7 @@ def PreProcess(log_dir=None):
561562
str(log_dir),
562563
current_path_file,
563564
)
565+
print(f"Save temp_run_file_path = '{str(log_dir)}'")
564566
ConfigModule.add_config_value("sectionOne", "sTestStepExecLogId", "node_cli", temp_ini_file)
565567

566568

0 commit comments

Comments
 (0)