Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
T
TestSpider
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Bugzilla
Bugzilla
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
尚立鹏
TestSpider
Commits
974120dc
Commit
974120dc
authored
Feb 15, 2023
by
ShangLiPeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify rpa
parent
025a4e15
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
33 additions
and
9 deletions
+33
-9
pom.xml
pom.xml
+5
-0
Main.java
src/main/java/com/greatchn/Main.java
+5
-1
LoginFunction.java
src/main/java/com/greatchn/etax/tianjin/LoginFunction.java
+1
-1
ChromeKits.java
src/main/java/com/greatchn/kits/ChromeKits.java
+12
-4
RpaCore.java
src/main/java/com/greatchn/rpa/RpaCore.java
+3
-1
RpaConfig.java
src/main/java/com/greatchn/rpa/config/RpaConfig.java
+1
-1
rpa.yaml
src/main/resources/rpa.yaml
+6
-1
No files found.
pom.xml
View file @
974120dc
...
...
@@ -158,6 +158,7 @@
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<version>
2.2.2.RELEASE
</version>
<configuration>
<excludes>
<exclude>
...
...
@@ -170,6 +171,7 @@
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<version>
3.10.1
</version>
<configuration>
<source>
17
</source>
<target>
17
</target>
...
...
@@ -197,6 +199,7 @@
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-dependency-plugin
</artifactId>
<version>
2.8
</version>
<executions>
<execution>
<id>
copy-dependencies
</id>
...
...
@@ -218,7 +221,9 @@
<!--三、把依赖也打进jar包:mainClass是jar包的main方法入口-->
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-assembly-plugin
</artifactId>
<version>
2.2-beta-5
</version>
<configuration>
<archive>
<manifest>
...
...
src/main/java/com/greatchn/Main.java
View file @
974120dc
package
com
.
greatchn
;
import
cn.hutool.core.io.resource.ClassPathResource
;
import
com.greatchn.kits.ChromeKits
;
import
com.greatchn.yzh.TaskExecutor
;
import
io.netty.util.internal.ResourcesUtil
;
import
java.awt.*
;
/**
* RPA With Selenium for Java 入口
...
...
@@ -11,8 +15,8 @@ import com.greatchn.yzh.TaskExecutor;
*/
public
class
Main
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
System
.
out
.
println
(
"准备结束chrome进程"
);
ChromeKits
.
killBrowser
();
ChromeKits
.
utilBrowserStart
(
"./files/chrome_no_proxy.bat"
);
new
TaskExecutor
();
}
}
\ No newline at end of file
src/main/java/com/greatchn/etax/tianjin/LoginFunction.java
View file @
974120dc
...
...
@@ -206,7 +206,7 @@ public class LoginFunction extends BaseFunction {
})();
"""
,
Object
.
class
);
rpa
().
listen
(
"apps/view/login.html"
);
}
catch
(
NoSuchElement
Exception
ignored
)
{
}
catch
(
Exception
ignored
)
{
// 尝试性操作异常不需要处理
}
}
...
...
src/main/java/com/greatchn/kits/ChromeKits.java
View file @
974120dc
package
com
.
greatchn
.
kits
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.io.resource.ClassPathResource
;
import
org.apache.commons.lang3.StringUtils
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.InputStreamReader
;
import
java.nio.charset.Charset
;
import
java.util.Arrays
;
import
java.util.Date
;
...
...
@@ -14,13 +17,18 @@ public class ChromeKits {
ProcessKits
.
killProcess
(
Arrays
.
asList
(
"firefox"
,
"geckodriver"
,
"crashreporter"
,
"chromedriver"
,
"chrome"
));
}
//创建浏览器
public
static
String
utilBrowserStart
(
String
batPath
)
throws
Exception
public
static
String
utilBrowserStart
(
String
cmd
)
{
Runtime
rt
=
Runtime
.
getRuntime
();
try
{
Process
process
=
rt
.
exec
(
new
File
(
batPath
).
getAbsolutePath
());
//cmd /c dir 是执行完dir命令后关闭命令窗口。
//cmd /k dir 是执行完dir命令后不关闭命令窗口。
//cmd /c start dir 会打开一个新窗口后执行dir指令,原窗口会关闭。
//cmd /k start dir 会打开一个新窗口后执行dir指令,原窗口不会关闭。
// String cmd="cmd /k "+new File(batPath).getAbsolutePath();
System
.
out
.
println
(
cmd
);
Process
process
=
rt
.
exec
(
cmd
);
// 获取启动返回信息
InputStreamReader
isr
=
new
InputStreamReader
(
process
.
getErrorStream
());
...
...
@@ -55,7 +63,7 @@ public class ChromeKits {
}
catch
(
Exception
e
)
{
throw
e
;
throw
new
RuntimeException
(
e
.
getMessage
())
;
}
}
}
src/main/java/com/greatchn/rpa/RpaCore.java
View file @
974120dc
...
...
@@ -3,6 +3,7 @@ package com.greatchn.rpa;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.map.MapUtil
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.greatchn.kits.ChromeKits
;
import
com.greatchn.kits.JacksonKits
;
import
com.greatchn.kits.RandomKits
;
import
com.greatchn.rpa.beans.Point
;
...
...
@@ -204,6 +205,7 @@ public class RpaCore {
}
//手动启动浏览器
if
(
this
.
config
.
isRemoteDebugging
()
==
true
)
{
ChromeKits
.
utilBrowserStart
(
this
.
config
.
getRemoteDebuggingCmd
());
options
.
setExperimentalOption
(
"debuggerAddress"
,
this
.
config
.
getRemoteDebuggingIP
()
+
":"
+
this
.
config
.
getRemoteDebuggingPort
());
}
//Mobo
...
...
src/main/java/com/greatchn/rpa/config/RpaConfig.java
View file @
974120dc
...
...
@@ -28,7 +28,7 @@ public class RpaConfig {
private
boolean
remoteDebugging
;
private
int
remoteDebuggingPort
;
private
String
remoteDebuggingIP
;
private
String
remoteDebuggingCmd
;
/**
* 使用默认配置文件加载配置
*
...
...
src/main/resources/rpa.yaml
View file @
974120dc
...
...
@@ -21,9 +21,14 @@ useSeleniumDrag: true
networkProxy
:
true
#是否使用selenium来自动启动浏览器
remoteDebugging
:
tru
e
remoteDebugging
:
fals
e
remoteDebuggingPort
:
9222
remoteDebuggingIP
:
"
127.0.0.1"
# cmd /b /Google/Chrome/Application/chrome.exe --remote-debugging-port=9222 --user-data-dir=/selenium/ChromeProfile --allow-pre-commit-input --disable-background-networking --disable-backgrounding-occluded-windows --disable-client-side-phishing-detection --disable-default-apps --disable-hang-monitor --disable-infobars --disable-popup-blocking --disable-prompt-on-repost --disable-sync --enable-blink-features=ShadowDOMV0 --enable-logging --ignore-certificate-errors --log-level=3 --no-service-autorun --password-store=basic --start-maximized --test-type --use-mock-keychain --flag-switches-begin --flag-switches-end
#remoteDebuggingCmd: "/Google/Chrome/Application/chrome.exe --remote-debugging-port=9222 --user-data-dir=/selenium/ChromeProfile --allow-pre-commit-input --disable-background-networking --disable-backgrounding-occluded-windows --disable-client-side-phishing-detection --disable-default-apps --disable-hang-monitor --disable-infobars --disable-popup-blocking --disable-prompt-on-repost --disable-sync --enable-blink-features=ShadowDOMV0 --enable-logging --ignore-certificate-errors --log-level=3 --no-service-autorun --password-store=basic --start-maximized --test-type --use-mock-keychain --flag-switches-begin --flag-switches-end"
#remoteDebuggingCmd: "cmd.exe /c start /b C:\\Google\\Chrome\\Application\\chrome.bat"
remoteDebuggingCmd
:
"
cmd.exe
/c
start
/b
C:
\\
Google
\\
Chrome
\\
Application
\\
chrome.bat"
scale
:
1.00
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment