diff --git a/ElectronJS/EasySpider_en.crx b/ElectronJS/EasySpider_en.crx
index 95103cb..7d1a530 100644
Binary files a/ElectronJS/EasySpider_en.crx and b/ElectronJS/EasySpider_en.crx differ
diff --git a/ElectronJS/EasySpider_zh.crx b/ElectronJS/EasySpider_zh.crx
index d9c50a3..17b1921 100644
Binary files a/ElectronJS/EasySpider_zh.crx and b/ElectronJS/EasySpider_zh.crx differ
diff --git a/ElectronJS/change_version.py b/ElectronJS/change_version.py
index b5c9a2d..a71b2d3 100644
--- a/ElectronJS/change_version.py
+++ b/ElectronJS/change_version.py
@@ -50,7 +50,7 @@ if __name__ == "__main__":
# index.html
file_path = "./src/index.html"
- update_file_version(file_path, version, key="当前版本/Current Version: v")
+ update_file_version(file_path, version, key="当前版本/Current Version: v")
# package.json
file_path = "./package.json"
diff --git a/ElectronJS/config.json b/ElectronJS/config.json
index d7f6cab..522f720 100644
--- a/ElectronJS/config.json
+++ b/ElectronJS/config.json
@@ -1 +1 @@
-{"webserver_address":"http://localhost","webserver_port":8074,"user_data_folder":"./user_data","absolute_user_data_folder":"D:\\Documents\\Projects\\EasySpider\\ElectronJS\\user_data"}
\ No newline at end of file
+{"webserver_address":"http://localhost","webserver_port":8074,"user_data_folder":"./user_data","absolute_user_data_folder":"D:\\Document\\Projects\\EasySpider\\ElectronJS\\user_data"}
\ No newline at end of file
diff --git a/ElectronJS/main.js b/ElectronJS/main.js
index 7707833..f089802 100644
--- a/ElectronJS/main.js
+++ b/ElectronJS/main.js
@@ -124,7 +124,7 @@ async function beginInvoke(msg, ws) {
flowchart_window.show();
// flowchart_window.openDevTools();
} else if (msg.type == 2) {
- //keyboard
+ // 键盘输入事件
// const robot = require("@jitsi/robotjs");
let keyInfo = msg.message.keyboardStr;
let handles = await driver.getAllWindowHandles();
@@ -137,6 +137,12 @@ async function beginInvoke(msg, ws) {
while (true) {
// console.log("handles");
try{
+ let iframe = msg.message.iframe;
+ let enter = false;
+ if (//i.test(keyInfo)) {
+ keyInfo = keyInfo.replace(//gi, '');
+ enter = true;
+ }
let h = order[len - 1];
console.log("current_handle", current_handle);
if(h != null && handles.includes(h)){
@@ -146,11 +152,42 @@ async function beginInvoke(msg, ws) {
}
// await driver.executeScript("window.stop();");
// console.log("executeScript");
- let element = await driver.findElement(By.xpath(msg.message.xpath));
- console.log("Find Element at handle: ", current_handle);
- await element.sendKeys(Key.HOME, Key.chord(Key.SHIFT, Key.END), keyInfo);
- console.log("send key");
- break;
+ if(!iframe){
+ let element = await driver.findElement(By.xpath(msg.message.xpath));
+ console.log("Find Element at handle: ", current_handle);
+ // 使用正则表达式匹配 '',不论大小写
+ await element.sendKeys(Key.HOME, Key.chord(Key.SHIFT, Key.END), keyInfo);
+ if(enter){
+ await element.sendKeys(Key.ENTER);
+ }
+ console.log("send key");
+ break;
+ } else {
+ let iframes = await driver.findElements(By.tagName('iframe'));
+ // 遍历所有的 iframe 并点击里面的元素
+ for(let i = 0; i < iframes.length; i++) {
+ let iframe = iframes[i];
+ // 切换到 iframe
+ await driver.switchTo().frame(iframe);
+ // 在 iframe 中查找并点击元素
+ let element;
+ try {
+ element = await driver.findElement(By.xpath(msg.message.xpath));
+ } catch (error) {
+ console.log('No such element found in the iframe');
+ }
+ if (element) {
+ await element.sendKeys(Key.HOME, Key.chord(Key.SHIFT, Key.END), keyInfo);
+ if(enter){
+ await element.sendKeys(Key.ENTER);
+ }
+ }
+ // 完成操作后切回主文档
+ await driver.switchTo().defaultContent();
+ }
+ break;
+ }
+
} catch (error) {
console.log("len", len);
len = len - 1;
@@ -186,7 +223,10 @@ async function beginInvoke(msg, ws) {
let message = JSON.parse(msg.message.pipe);
let type = message.type;
console.log("FROM Browser: ", message);
+ console.log("Iframe:", message.iframe);
if(type.indexOf("Click")>=0){
+ // 鼠标点击事件
+ let iframe = message.iframe;
let handles = await driver.getAllWindowHandles();
console.log("handles", handles);
let exit = false;
@@ -199,15 +239,39 @@ async function beginInvoke(msg, ws) {
let h = order[len - 1];
console.log("current_handle", current_handle);
if(h != null && handles.includes(h)){
- await driver.switchTo().window(h);
+ await driver.switchTo().window(h); //执行失败会抛出异常
current_handle = h;
console.log("switch to handle: ", h);
}
- let element = await driver.findElement(By.xpath(message.xpath));
- await element.click();
- break;
+ //下面是找到窗口的情况下
+ if(!iframe){
+ let element = await driver.findElement(By.xpath(message.xpath));
+ await element.click();
+ break;
+ } else {
+ let iframes = await driver.findElements(By.tagName('iframe'));
+ // 遍历所有的 iframe 并点击里面的元素
+ for(let i = 0; i < iframes.length; i++) {
+ let iframe = iframes[i];
+ // 切换到 iframe
+ await driver.switchTo().frame(iframe);
+ // 在 iframe 中查找并点击元素
+ let element;
+ try {
+ element = await driver.findElement(By.xpath(message.xpath));
+ } catch (error) {
+ console.log('No such element found in the iframe');
+ }
+ if (element) {
+ await element.click();
+ }
+ // 完成操作后切回主文档
+ await driver.switchTo().defaultContent();
+ }
+ break;
+ }
} catch (error) {
- console.log("len", len);
+ console.log("len", len); //如果没有找到元素,就切换到下一个窗口
len = len - 1;
if (len == 0) {
break;
@@ -321,7 +385,6 @@ async function runBrowser(lang = "en", user_data_folder = '', mobile = false) {
}
options.addExtensions(path.join(__dirname, "XPathHelper.crx"));
options.setChromeBinaryPath(chromeBinaryPath);
- options.add
if (user_data_folder != "") {
let dir = path.join(task_server.getDir(), user_data_folder);
console.log(dir);
@@ -445,4 +508,4 @@ app.on('window-all-closed', function () {
function arrayDifference(arr1, arr2) {
return arr1.filter(item => !arr2.includes(item));
-}
\ No newline at end of file
+}
diff --git a/ElectronJS/src/index.html b/ElectronJS/src/index.html
index b8b3616..ce88a84 100644
--- a/ElectronJS/src/index.html
+++ b/ElectronJS/src/index.html
@@ -40,7 +40,7 @@
English
- 当前版本/Current Version: v0.3.5
+ 当前版本/Current Version: v0.3.5
Github最新版本/Newest Version:{{newest_version}}
@@ -111,13 +111,13 @@
Start Design
+ style="margin-top: 15px; width: 320px;height:60px;padding-top:12px;color:white">Start Design
Start Design (Mobile)
+ style="margin-top: 15px; width: 320px;height:60px;padding-top:12px;color:white">Start Design (Mobile)
- Go to Home Page
+ Go to Home Page
@@ -175,13 +175,13 @@
开始设计
+ style="margin-top: 15px; width: 320px;height:60px;padding-top:12px;color:white">开始设计
开始设计(手机模式)
+ style="margin-top: 15px; width: 320px;height:60px;padding-top:12px;color:white">开始设计(手机模式)
- 返回首页
+ 返回首页
@@ -193,4 +193,4 @@