Skip to content

Commit e9cce35

Browse files
Merge pull request #482 from AutomationSolutionz/zai
Save dom of web and variables to server
2 parents 9de324f + 248de3b commit e9cce35

17 files changed

Lines changed: 201 additions & 48 deletions

File tree

Apps/Web/AI_Recorder_2/dist/assets/index-ZxKYERgc.js renamed to Apps/Web/AI_Recorder_2/dist/assets/index-iqPt-ocH.js

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Apps/Web/AI_Recorder_2/dist/assets/index-ZxKYERgc.js.map renamed to Apps/Web/AI_Recorder_2/dist/assets/index-iqPt-ocH.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Apps/Web/AI_Recorder_2/dist/background/data.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
"stepName": "Step_name",
66
"url": "",
77
"apiKey": "",
8-
"jwtKey": ""
8+
"jwtKey": "",
9+
"nodeId": ""
910
}

Apps/Web/AI_Recorder_2/dist/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<!-- <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous"> -->
1212
<!-- <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script> -->
1313

14-
<script type="module" crossorigin src="/assets/index-ZxKYERgc.js"></script>
14+
<script type="module" crossorigin src="/assets/index-iqPt-ocH.js"></script>
1515
<link rel="stylesheet" crossorigin href="/assets/index-CrwDEiCX.css">
1616
</head>
1717
<body>

Apps/Web/AI_Recorder_2/public/background/data.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
"stepName": "Step_name",
66
"url": "",
77
"apiKey": "",
8-
"jwtKey": ""
8+
"jwtKey": "",
9+
"nodeId": ""
910
}

Apps/Web/AI_Recorder_2/src/App.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,9 @@ function App() {
314314
TC_Id: result.meta_data.testNo,
315315
step_sequence: result.meta_data.stepNo,
316316
step_data: JSON.stringify(actions.map(action => {
317-
return action.main;
317+
return action.main.map((row, rowIndex) => {
318+
return [...row, rowIndex + 1];
319+
});
318320
})),
319321
step_id: result.meta_data.stepId,
320322
dataset_name: JSON.stringify(actions.map((action, idx) => {

Apps/Web/aiplugin/background.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ const activeIcon = 'active-64.png';
55
const defaultIcon = 'small_logo.png';
66
var zeuz_url;
77
var zeuz_key;
8+
var zeuz_node_id;
89

910
fetch("data.json")
1011
.then(Response => Response.json())
1112
.then(data => {
12-
zeuz_url = data.zeuz_url;
13-
zeuz_key = data.zeuz_key;
14-
console.log(data);
15-
console.log(zeuz_url);
16-
console.log(zeuz_key);
13+
zeuz_url = data.url;
14+
zeuz_key = data.apiKey;
15+
zeuz_node_id = data.nodeId;
1716
browserAppData.storage.local.set({
1817
url: zeuz_url,
1918
key: zeuz_key,
19+
nodeId: zeuz_node_id,
2020
},
2121
function() {
2222
console.log("Logged in successfully!");
@@ -137,7 +137,6 @@ browserAppData.runtime.onMessage.addListener(
137137
function(request, sender, sendResponse) {
138138
if (request.apiName == 'ai_record_single_action') {
139139
var url = `${zeuz_url}/ai_record_single_action/`
140-
console.log("zeuz_key", zeuz_key)
141140
fetch(url, {
142141
method: "POST",
143142
headers: {
@@ -149,6 +148,21 @@ browserAppData.runtime.onMessage.addListener(
149148
.then(response => response.json())
150149
.then(text => {console.log(text);sendResponse(text);})
151150

151+
var url = `${zeuz_url}/node_ai_contents/`
152+
fetch(url, {
153+
method: "POST",
154+
headers: {
155+
// "Content-Type": "application/json",
156+
"X-Api-Key": zeuz_key,
157+
},
158+
body: JSON.stringify({
159+
"dom_web": {"dom": request.html},
160+
"node_id": zeuz_node_id
161+
}),
162+
})
163+
.then(response => response.json())
164+
.then(text => {console.log(text);sendResponse(text);})
165+
152166
return true; // Will respond asynchronously.
153167
}
154168
}

Apps/Web/aiplugin/data.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
{
2-
"zeuz_url": "__ZeuZ__UrL_maPP",
3-
"zeuz_key": "__ZeuZ__KeY_maPP"
2+
"testNo": "TEST-0000",
3+
"testName": "Test_name",
4+
"stepNo": 0,
5+
"stepName": "Step_name",
6+
"url": "",
7+
"apiKey": "",
8+
"jwtKey": "",
9+
"nodeId": ""
410
}

Apps/Web/aiplugin/inspect.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,11 @@ class Inspector {
5050

5151
}
5252

53-
async function send_data(server_url, api_key, data, modal_id) {
53+
async function send_data(server_url, api_key, data, modal_id, refinedHtml) {
5454
browserAppData.runtime.sendMessage({
5555
apiName: 'ai_record_single_action',
5656
data: data,
57+
html: refinedHtml,
5758
},
5859
response => {
5960
insert_modal_text(response, modal_id);
@@ -150,7 +151,7 @@ class Inspector {
150151
"action_type": "selenium"
151152
});
152153

153-
send_data(server_url, api_key, data, this.modalNode);
154+
send_data(server_url, api_key, data, this.modalNode, refinedHtml);
154155

155156
});
156157
// remove zeuz attribute
@@ -216,12 +217,13 @@ class Inspector {
216217

217218
refinedHtml = refinedHtml.replace(/[^\x00-\x7F]/g, '');
218219
refinedHtml = refinedHtml.replace(/[\x00-\x1F\x7F]/g, '');
220+
refinedHtml = refinedHtml.replace(/\s+/g, ' ').replace(/>\s+</g, '><');
219221
var data = JSON.stringify({
220222
"page_src": refinedHtml,
221223
"action_type": "selenium"
222224
});
223225

224-
send_data(server_url, api_key, data, this.modalNode);
226+
send_data(server_url, api_key, data, this.modalNode, refinedHtml);
225227

226228
});
227229
// remove zeuz attribute

Framework/Built_In_Automation/Sequential_Actions/sequential_actions.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,6 @@
8383
step_exit_fail_called = False
8484
step_exit_pass_called = False
8585

86-
# Get node ID and set as a Shared Variable
87-
machineInfo = CommonUtil.MachineInfo() # Create instance
88-
node_id = machineInfo.getLocalUser() # Get Username+Node ID
89-
sr.Set_Shared_Variables(
90-
"node_id", node_id, protected=True
91-
) # Save as protected shared variable
92-
9386
from pathlib import Path
9487
if os.path.exists(Path(__file__).parent.parent.parent.parent / "bypass.json"):
9588
bypass_exist = True

0 commit comments

Comments
 (0)