Skip to content

Commit e919fa3

Browse files
Merge pull request #447 from AutomationSolutionz/recorder
Recorder new ui and event-listeners
2 parents a781e2a + a8c7c16 commit e919fa3

30 files changed

+3579
-1549
lines changed

Apps/Web/AI_Recorder_2/dist/assets/index-D8ojZ2zq.css renamed to Apps/Web/AI_Recorder_2/dist/assets/index-BlYQBfWo.css

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/assets/index-DLSinZ59.js

Lines changed: 265 additions & 0 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-DLSinZ59.js.map

Lines changed: 1 addition & 0 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-DwaNsfXA.js

Lines changed: 0 additions & 60 deletions
This file was deleted.

Apps/Web/AI_Recorder_2/dist/assets/index-DwaNsfXA.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ async function open_panel_2(tab) {
183183

184184
result = await browserAppData.storage.local.get('window');
185185
var win = await chrome.windows.getCurrent();
186-
var height = Math.max(Math.round(win.height*0.9), 700) ;
187-
var width = Math.max(Math.round(win.width*0.35), 600);
186+
var height = Math.max(Math.round(win.height*1), 700) ;
187+
var width = Math.max(Math.round(win.width*0.20), 400);
188188
if (result) {
189189
try {
190190
result = result.window;
@@ -257,6 +257,7 @@ browserAppData.windows.onRemoved.addListener(function(windowId) {
257257

258258
var port;
259259
browserAppData.contextMenus.onClicked.addListener(function(info, tab) {
260+
console.log('context-menu', info.menuItemId)
260261
port.postMessage({ cmd: info.menuItemId });
261262
});
262263

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

Lines changed: 109 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,21 @@ fetch("./data.json")
88

99
const browserAppData = chrome || browser;
1010

11+
function generateId({stack, command, url, xpath}){
12+
if (stack){
13+
for (const item of Object.keys(Stack)) {
14+
if(Stack[item] && Stack[item][0].command === command && Stack[item][0].url === url && Stack[item][0].xpath === xpath)
15+
return item
16+
}
17+
}
18+
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
19+
let id = '';
20+
for (let i = 0; i < 8; i++) {
21+
id += characters.charAt(Math.floor(Math.random() * characters.length));
22+
}
23+
return id;
24+
}
25+
1126
var notificationCount = 0;
1227
function notification(command) {
1328
let tempCount = String(notificationCount);
@@ -39,12 +54,23 @@ var action_name_convert = {
3954
}
4055

4156
async function fetchAIData(id, command, value, url, document){
42-
browserAppData.runtime.sendMessage({
43-
action: 'record-start',
44-
data: {
45-
id:id
46-
},
47-
})
57+
if (command === 'keystroke keys'){
58+
let keystroke = {
59+
id: id,
60+
action: 'keystroke keys',
61+
element: "",
62+
is_disable: false,
63+
name: `keystroke: ${value}`,
64+
value: url,
65+
main: [['keystroke keys', 'selenium action', value]],
66+
xpath: "",
67+
};
68+
browserAppData.runtime.sendMessage({
69+
action: 'record-finish',
70+
data: keystroke,
71+
})
72+
return;
73+
}
4874
if (command === 'go to link'){
4975
let go_to_link = {
5076
id: id,
@@ -137,24 +163,95 @@ async function fetchAIData(id, command, value, url, document){
137163
})
138164
}
139165

140-
async function record_action(id, command, value, url, document){
141-
if (Object.keys(action_name_convert).includes(command)) command = action_name_convert[command];
142-
notification(command);
143-
fetchAIData(id, command, value, url, document);
166+
var Stack = {}
167+
async function record_action(id, command, xpath, value, url, tagName, document, stack){
168+
let stacked_id = ''
169+
if (stack){
170+
if (!(id in Stack)){
171+
Stack[id] = [{
172+
id: id,
173+
command: command,
174+
xpath: xpath,
175+
value: value,
176+
url: url,
177+
tagName: tagName,
178+
document: document
179+
}]
180+
browserAppData.runtime.sendMessage({
181+
action: 'record-start',
182+
data: {
183+
id:id
184+
},
185+
})
186+
}
187+
else if(
188+
Stack[id][0].command == command &&
189+
Stack[id][0].xpath == xpath &&
190+
Stack[id][0].url == url
191+
){
192+
Stack[id].push({
193+
id: id,
194+
command: command,
195+
xpath: xpath,
196+
value: value,
197+
url: url,
198+
tagName: tagName,
199+
document: document
200+
})
201+
}
202+
stacked_id = id
203+
}
204+
for (const item of Object.keys(Stack)) {
205+
if (item === stacked_id)
206+
continue
207+
let _id = Stack[item][Stack[item].length-1].id
208+
let _command = Stack[item][Stack[item].length-1].command
209+
let _value = Stack[item][Stack[item].length-1].value
210+
let _url = Stack[item][Stack[item].length-1].url
211+
let _document = Stack[item][Stack[item].length-1].document
212+
if (Object.keys(action_name_convert).includes(_command))
213+
_command = action_name_convert[_command];
214+
notification(_command);
215+
fetchAIData(_id, _command, _value, _url, _document);
216+
delete Stack[item]
217+
}
218+
219+
if(!stack){
220+
browserAppData.runtime.sendMessage({
221+
action: 'record-start',
222+
data: {
223+
id:id
224+
},
225+
})
226+
if (Object.keys(action_name_convert).includes(command)) command = action_name_convert[command];
227+
notification(command);
228+
fetchAIData(id, command, value, url, document);
229+
}
144230
}
231+
145232
browserAppData.runtime.onMessage.addListener(
146233
function(request, sender, sendResponse) {
147234
if (request.action == 'start_recording') {
235+
Stack = {}
148236
notificationCount = 0;
149237
}
150238
else if (request.action == 'record_action') {
239+
let id = generateId({
240+
stack: request.stack,
241+
command: request.command,
242+
url: request.url,
243+
xpath: request.xpath,
244+
})
245+
console.log('action_name =',request.command)
151246
record_action(
152-
request.id,
247+
id,
153248
request.command,
154-
// request.target,
249+
request.xpath,
155250
request.value,
156251
request.url,
252+
request.tagName,
157253
request.document,
254+
request.stack,
158255
);
159256
}
160257
}

0 commit comments

Comments
 (0)