Skip to content

Commit 7b71055

Browse files
Merge pull request #371 from AutomationSolutionz/recorder
Recorder
2 parents 836d53d + 2fbbe01 commit 7b71055

File tree

17 files changed

+1332
-699
lines changed

17 files changed

+1332
-699
lines changed

Apps/Web/AI_Recorder/background/back.js

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,40 @@
1+
const browserAppData = chrome || browser;
2+
3+
import './back_zeuz.js';
4+
// import '../common_files/poly_fill.js';
15

26
/* Zeuz function start */
37
var master = {};
48
var clickEnabled = true;
59

610
/* Open panel */
711

12+
// import {getWindowSize} from "/back_zeuz.js";
13+
function getWindowSize(callback) {
14+
chrome.storage.local.get('window', function(result) {
15+
var height = 740;
16+
//var width = 780;
17+
var width = 1110;
18+
if (result) {
19+
try {
20+
result = result.window;
21+
if (result.height) {
22+
height = result.height;
23+
}
24+
if (result.width) {
25+
width = result.width;
26+
}
27+
} catch (e) {
28+
}
29+
}
30+
callback(height, width);
31+
});
32+
}
33+
834
function open_panel(tab) {
935
let contentWindowId = tab.windowId;
1036
if (master[contentWindowId] != undefined) {
11-
browser.windows.update(master[contentWindowId], {
37+
browserAppData.windows.update(master[contentWindowId], {
1238
focused: true
1339
}).catch(function(e) {
1440
master[contentWindowId] == undefined;
@@ -25,8 +51,8 @@ function open_panel(tab) {
2551
}, 1000);
2652

2753
var f = function(height, width) {
28-
browser.windows.create({
29-
url: browser.runtime.getURL("panel/index.html"),
54+
browserAppData.windows.create({
55+
url: browserAppData.runtime.getURL("panel/index.html"),
3056
type: "popup",
3157
//height: 705,
3258
height: height,
@@ -41,7 +67,7 @@ function open_panel(tab) {
4167
clearInterval(interval);
4268
}
4369

44-
browser.tabs.query({
70+
browserAppData.tabs.query({
4571
active: true,
4672
windowId: panelWindowInfo.id,
4773
status: "complete"
@@ -61,7 +87,7 @@ function open_panel(tab) {
6187
}, 200);
6288
});
6389
}).then(function bridge(panelWindowInfo){
64-
return browser.tabs.sendMessage(panelWindowInfo.tabs[0].id, {
90+
return browserAppData.tabs.sendMessage(panelWindowInfo.tabs[0].id, {
6591
selfWindowId: panelWindowInfo.id,
6692
commWindowId: contentWindowId
6793
});
@@ -74,55 +100,55 @@ function open_panel(tab) {
74100

75101
/* Create menu */
76102
function create_menus() {
77-
browser.contextMenus.create({
103+
browserAppData.contextMenus.create({
78104
id: "verifyText",
79105
title: "verifyText",
80106
documentUrlPatterns: ["<all_urls>"],
81107
contexts: ["all"]
82108
});
83-
browser.contextMenus.create({
109+
browserAppData.contextMenus.create({
84110
id: "verifyTitle",
85111
title: "verifyTitle",
86112
documentUrlPatterns: ["<all_urls>"],
87113
contexts: ["all"]
88114
});
89-
browser.contextMenus.create({
115+
browserAppData.contextMenus.create({
90116
id: "verifyValue",
91117
title: "verifyValue",
92118
documentUrlPatterns: ["<all_urls>"],
93119
contexts: ["all"]
94120
});
95-
browser.contextMenus.create({
121+
browserAppData.contextMenus.create({
96122
id: "assertText",
97123
title: "assertText",
98124
documentUrlPatterns: ["<all_urls>"],
99125
contexts: ["all"]
100126
});
101-
browser.contextMenus.create({
127+
browserAppData.contextMenus.create({
102128
id: "assertTitle",
103129
title: "assertTitle",
104130
documentUrlPatterns: ["<all_urls>"],
105131
contexts: ["all"]
106132
});
107-
browser.contextMenus.create({
133+
browserAppData.contextMenus.create({
108134
id: "assertValue",
109135
title: "assertValue",
110136
documentUrlPatterns: ["<all_urls>"],
111137
contexts: ["all"]
112138
});
113-
browser.contextMenus.create({
139+
browserAppData.contextMenus.create({
114140
id: "storeText",
115141
title: "storeText",
116142
documentUrlPatterns: ["<all_urls>"],
117143
contexts: ["all"]
118144
});
119-
browser.contextMenus.create({
145+
browserAppData.contextMenus.create({
120146
id: "storeTitle",
121147
title: "storeTitle",
122148
documentUrlPatterns: ["<all_urls>"],
123149
contexts: ["all"]
124150
});
125-
browser.contextMenus.create({
151+
browserAppData.contextMenus.create({
126152
id: "storeValue",
127153
title: "storeValue",
128154
documentUrlPatterns: ["<all_urls>"],
@@ -131,25 +157,25 @@ function create_menus() {
131157
}
132158

133159

134-
browser.browserAction.onClicked.addListener(open_panel);
135-
browser.windows.onRemoved.addListener(function(windowId) {
160+
browserAppData.action.onClicked.addListener(open_panel);
161+
browserAppData.windows.onRemoved.addListener(function(windowId) {
136162
let keys = Object.keys(master);
137163
for (let key of keys) {
138164
if (master[key] === windowId) {
139165
delete master[key];
140166
if (keys.length === 1) {
141-
browser.contextMenus.removeAll();
167+
browserAppData.contextMenus.removeAll();
142168
}
143169
}
144170
}
145171
});
146172

147173
var port;
148-
browser.contextMenus.onClicked.addListener(function(info, tab) {
174+
browserAppData.contextMenus.onClicked.addListener(function(info, tab) {
149175
port.postMessage({ cmd: info.menuItemId });
150176
});
151177

152-
browser.runtime.onConnect.addListener(function(m) {
178+
browserAppData.runtime.onConnect.addListener(function(m) {
153179
port = m;
154180
});
155181

Apps/Web/AI_Recorder/background/back_zeuz.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
var attachedTabs = {};
2-
2+
const browser = chrome || browser;
33
/* Fetch the window size */
44
function getWindowSize(callback) {
55
chrome.storage.local.get('window', function(result) {

Apps/Web/AI_Recorder/common_files/poly_fill.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const browser = chrome || browser;
12
(function (global, factory) {
23
if (typeof define === "function" && define.amd) {
34
define("webextension-polyfill", ["module"], factory);
@@ -8,6 +9,7 @@
89
exports: {}
910
};
1011
factory(mod);
12+
console.log(global);
1113
global.browser = mod.exports;
1214
}
1315
})(this, function (module) {

Apps/Web/AI_Recorder/content/injecter.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// inject scripts for promot command
2+
const browser = chrome || browser;
23
var injectingScript = document.createElement("script");
34
injectingScript.src = browser.runtime.getURL("page/prompt.js");
45
(document.head || document.documentElement).appendChild(injectingScript);

Apps/Web/AI_Recorder/content/jquery.simulate.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
/*!
2-
*/
3-
1+
var jQuery;
2+
import('../panel/assets/js/lib/jquery-ui.min.js').then((module) => {
3+
// Access the exported variable from the module
4+
jQuery = module;
5+
}).catch((error) => {
6+
console.error('Error loading the module:', error);
7+
});
48
;(function( $, undefined ) {
59

610
var rkeyEvent = /^key/,

Apps/Web/AI_Recorder/content/recorder.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,17 @@ class Recorder {
4242
/* Recorder */
4343
record(command, target, value, insertBeforeLastCommand, actualFrameLocation) {
4444
let self = this;
45-
browser.runtime.sendMessage({
45+
console.log("... Action recorder start");
46+
let signal = {
4647
command: command,
4748
target: target,
4849
value: value,
4950
insertBeforeLastCommand: insertBeforeLastCommand,
5051
frameLocation: (actualFrameLocation != undefined ) ? actualFrameLocation : this.frameLocation,
51-
}).catch (function(reason) {
52+
};
53+
console.log(signal);
54+
browser.runtime.sendMessage(signal).catch (function(reason) {
55+
console.log(reason);
5256
});
5357
}
5458

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
{
2+
"description": "This ZeuZ Chrome extension allow you to record a test case, use ZeuZ AI to get an acurate page element, and play back the test case right in your browser.",
3+
"manifest_version": 2,
4+
"name": "ZeuZ Test Recorder",
5+
"version": "2.1",
6+
"icons":
7+
{
8+
"16": "panel/assets/images/small_logo.png",
9+
"48": "panel/assets/images/small_logo.png",
10+
"128": "panel/assets/images/small_logo.png"
11+
},
12+
"permissions": [
13+
"tabs",
14+
"activeTab",
15+
"webRequest",
16+
"contextMenus",
17+
"downloads",
18+
"webNavigation",
19+
"notifications",
20+
"http://*/",
21+
"https://*/",
22+
"storage",
23+
"unlimitedStorage",
24+
"<all_urls>",
25+
"debugger",
26+
"clipboardRead",
27+
"clipboardWrite"
28+
],
29+
30+
"homepage_url":"https://www.zeuz.ai/",
31+
32+
"content_security_policy": "script-src 'self' 'unsafe-eval' https://ssl.google-analytics.com; object-src 'self'",
33+
34+
"content_scripts": [
35+
{
36+
"matches": ["<all_urls>"],
37+
"js": [
38+
"common_files/poly_fill.js",
39+
"content/injecter.js"
40+
],
41+
"all_frames": true,
42+
"match_about_blank": true,
43+
"run_at": "document_start"
44+
},
45+
{
46+
"matches": ["<all_urls>"],
47+
"js": [
48+
"content/detect_bowser.js",
49+
"content/atoms_js.js",
50+
"content/utils_js.js",
51+
"content/commandhandlers.js",
52+
"content/browserbot.js",
53+
"common_files/escape.js",
54+
"content/sel_api.js",
55+
"content/loc_builders.js",
56+
"content/recorder.js",
57+
"content/rec_handlers.js",
58+
"content/commandreceiver.js",
59+
"content/target_selecter.js",
60+
"content/lib/sizzle_js.js",
61+
"content/content_zeuz.js"
62+
],
63+
"match_about_blank": true,
64+
"all_frames": true
65+
},
66+
{
67+
"matches": ["<all_urls>"],
68+
"js": ["content/jquery.simulate.js"],
69+
"match_about_blank": true,
70+
"all_frames": true
71+
}
72+
],
73+
74+
"background":
75+
{
76+
"scripts": [
77+
"content/detect_bowser.js",
78+
"common_files/poly_fill.js",
79+
"background/back.js",
80+
"background/back_zeuz.js"
81+
]
82+
},
83+
84+
"browser_action":
85+
{
86+
"default_icon": "panel/assets/images/small_logo.png",
87+
"default_title": "ZeuZ"
88+
},
89+
90+
"web_accessible_resources": [
91+
"page/prompt.js",
92+
"page/runScript.js"
93+
],
94+
95+
"offline_enabled": true
96+
}

0 commit comments

Comments
 (0)