Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Apps/Web/AI_Recorder/content/recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ class Recorder {
data: data,
dataj: dataj,
},
response => {
resp => {
let response = resp.ai_choices;
response[0].short.value = value;
if (value) response[0].data_set[response[0].data_set.length-1][response[0].data_set[0].length-1] = value;
this.recorded_actions[idx] = {
Expand Down
22 changes: 21 additions & 1 deletion Apps/Web/aiplugin/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,24 @@ if (navigator.userAgentData.platform.toLowerCase().includes('mac')){
browserAppData.action.setTitle({
title: "Cmd + Shift + X"
});
}
}
browserAppData.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
if (request.apiName == 'ai_record_single_action') {
var url = `${zeuz_url}/ai_record_single_action/`

fetch(url, {
method: "POST",
headers: {
// "Content-Type": "application/json",
"X-Api-Key": zeuz_key,
},
body: request.data,
})
.then(response => response.json())
.then(text => {console.log(text);sendResponse(text);})

return true; // Will respond asynchronously.
}
}
);
104 changes: 26 additions & 78 deletions Apps/Web/aiplugin/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Inspector {

function insert_modal_text(response, modal_id) {
console.log("insert_modal_text ..................")
if (response.status == 200) {
if (response["info"] == "success") {
// show message about element
const modalText = 'Element data was recorded. Please Click "Add by AI"';
console.log(modalText);
Expand All @@ -45,29 +45,20 @@ class Inspector {
}
return true;
}
console.error(response["info"]);
return false;

}

async function send_data(server_url, api_key, data, backup_data, modal_id) {
let resp = await fetch(server_url + "/api/contents/", {
method: "POST", // or 'PUT'
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${api_key}`,
},
body: data,
});
if (insert_modal_text(resp, modal_id)) return;
resp = await fetch(server_url + "/api/contents/", {
method: "POST", // or 'PUT'
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${api_key}`,
},
body: backup_data,
});
insert_modal_text(resp, modal_id);
async function send_data(server_url, api_key, data, modal_id) {
browserAppData.runtime.sendMessage({
apiName: 'ai_record_single_action',
data: data,
},
response => {
insert_modal_text(response, modal_id);
}
);
}

// check if we are locating sibling now
Expand All @@ -92,42 +83,29 @@ class Inspector {

// Get full page html, remove <style> and <script> tags //
// create a new div container
var div = document.createElement('div');
var html = document.createElement('html');
var myString = document.documentElement.outerHTML;

// assign your HTML to div's innerHTML
div.innerHTML = myString;
html.innerHTML = myString;

// get all <script> elements from div
var elements = div.getElementsByTagName('script');
var elements = html.getElementsByTagName('head');
while (elements[0])
elements[0].parentNode.removeChild(elements[0])

// remove all <script> elements
// get all <script> elements from div
var elements = html.getElementsByTagName('script');
while (elements[0])
elements[0].parentNode.removeChild(elements[0])

// get all <style> elements from div
var elements = div.getElementsByTagName('style');

// remove all <style> elements
var elements = html.getElementsByTagName('style');
while (elements[0])
elements[0].parentNode.removeChild(elements[0])

// get div's innerHTML into a new variable
var refinedHtml = div.innerHTML;


const tracker_info = {
'elem': this.elem['html'], // main element not entire html. Not required in backend !!
'html': refinedHtml,
'url': window.location.href,
'source': 'web'
}

const backup_tracker_info = {
'elem': this.elem['original_html'], // main element not entire html. Not required in backend !!
'url': window.location.href,
'source': 'web'
}
var refinedHtml = html.outerHTML;

// choose sibling element
browserAppData.storage.local.get(['sibling'], function (result) {
Expand Down Expand Up @@ -161,16 +139,11 @@ class Inspector {
// send data to zeuz server directly

var data = JSON.stringify({
"content": JSON.stringify(tracker_info),
"source": "web"
"page_src": refinedHtml,
"action_type": "selenium"
});

var backup_data = JSON.stringify({
"content": JSON.stringify(backup_tracker_info),
"source": "web"
});

send_data(server_url, api_key, data, backup_data, this.modalNode);
send_data(server_url, api_key, data, this.modalNode);

});
// remove zeuz attribute
Expand Down Expand Up @@ -224,26 +197,6 @@ class Inspector {
var refinedHtml = div.innerHTML;


// prepare data to send
const tracker_info = {
'elem': result.main,
'sibling': this.sibling['html'],
'html': refinedHtml,
'url': window.location.href,
'source': 'web'
}

const backup_tracker_info = {
'elem': result.main,
'sibling': this.sibling['original_html'],
'url': window.location.href,
'source': 'web'
}


// send data to zeuz server
// this.sendData(tracker_info, backup_tracker_info);

// get url-key and send data to zeuz
browserAppData.storage.local.get(['key', 'url'], function (result) {

Expand All @@ -255,16 +208,11 @@ class Inspector {
// send data to zeuz server directly

var data = JSON.stringify({
"content": JSON.stringify(tracker_info),
"source": "web"
});

var backup_data = JSON.stringify({
"content": JSON.stringify(backup_tracker_info),
"source": "web"
"page_src": refinedHtml,
"action_type": "selenium"
});

send_data(server_url, api_key, data, backup_data, this.modalNode);
send_data(server_url, api_key, data, this.modalNode);

});
// remove zeuz attribute
Expand Down
20 changes: 5 additions & 15 deletions Apps/Windows/ZeuZ_Windows_Inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,29 +117,19 @@ def Authenticate():

def Upload(auth_thread, window_name):
try:
global auth
if not auth:
auth = auth_thread.result().json()["token"]
Authorization = 'Bearer ' + auth
url = server + "/" if server[-1] != "/" else server
url += "api/contents/"
url += "ai_record_single_action/"
content = json.dumps({
'html': xml_str,
'page_src': xml_str,
"action_type": "windows",
"exact_path": {"path": path, "priority": path_priority},
"window_name": window_name
})

payload = json.dumps({
"content": content,
"source": "windows"
})
headers = {
'Authorization': Authorization,
'Content-Type': 'application/json'

"X-Api-Key": api_key,
}

r = requests.request("POST", url, headers=headers, data=payload, verify=False)
r = requests.request("POST", url, headers=headers, data=content, verify=False)
response = r.json()
del response["content"]
r.ok and print("Content successfully sent to AI Engine\n")
Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# Changelog


# Version 17
# Version 18

### [Current changes]
-

### [18.0.0][Nov 5, 2023]
- **[Change]** AI Inspector new api integrated

# Version 17
### [17.1.0][Oct 23, 2023]
- **[Fix]** Inspector bug fixes and improvements
- **[Fix]** Appium desired capabilities fix
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ def set_extension_variables():
zeuz_url_var = text[zeuz_url_var_idx:zeuz_url_var_idx+text[zeuz_url_var_idx:].find("\n")]
zeuz_key_var_idx = text.find("let zeuz_key = ")
zeuz_key_var = text[zeuz_key_var_idx:zeuz_key_var_idx+text[zeuz_key_var_idx:].find("\n")]
file.write(text.replace(zeuz_url_var, f"let zeuz_url = '{url}';", 1).replace(zeuz_key_var, f"let zeuz_key = '{jwtKey}';", 1))
file.write(text.replace(zeuz_url_var, f"let zeuz_url = '{url}';", 1).replace(zeuz_key_var, f"let zeuz_key = '{apiKey}';", 1))
except:
return CommonUtil.Exception_Handler(sys.exc_info(), None, "Could not load inspector extension")

Expand Down
4 changes: 2 additions & 2 deletions Framework/Version.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[ZeuZ Python Version]
version = 17.1.0
version = 18.0.0
[Release Date]
date = October 23, 2023
date = November 5, 2023