Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
A
auto-test-case
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄承天
auto-test-case
Commits
29d2eb92
提交
29d2eb92
authored
12月 08, 2020
作者:
黄承天
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[fix]
增加对输入参数的非空判断
上级
fa8a57cf
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
6 行增加
和
4 行删除
+6
-4
SeleniumExecutor.java
...main/java/com/zjty/autotest/service/SeleniumExecutor.java
+3
-0
WebDriverUtil.java
src/main/java/com/zjty/autotest/util/WebDriverUtil.java
+3
-4
没有找到文件。
src/main/java/com/zjty/autotest/service/SeleniumExecutor.java
浏览文件 @
29d2eb92
...
...
@@ -12,6 +12,7 @@ import com.zjty.autotest.util.JavaScriptUtil;
import
com.zjty.autotest.util.WebDriverUtil
;
import
com.zjty.autotest.websocket.WebSocketServer
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.logging.log4j.util.Strings
;
import
org.openqa.selenium.*
;
import
org.openqa.selenium.interactions.Actions
;
import
org.openqa.selenium.support.ui.Select
;
...
...
@@ -140,6 +141,7 @@ public class SeleniumExecutor {
if
(
nonNull
(
params
))
{
driver
.
manage
().
deleteAllCookies
();
for
(
Param
param
:
params
)
{
if
(
Strings
.
isNotBlank
(
param
.
getName
())&&
Strings
.
isNotBlank
(
param
.
getValue
())){
switch
(
param
.
getType
())
{
case
COOKIES:
driver
.
manage
().
addCookie
(
new
Cookie
(
param
.
getName
(),
param
.
getValue
()));
...
...
@@ -150,6 +152,7 @@ public class SeleniumExecutor {
}
}
}
}
/**
* 执行一个步骤
...
...
src/main/java/com/zjty/autotest/util/WebDriverUtil.java
浏览文件 @
29d2eb92
...
...
@@ -14,7 +14,7 @@ import org.slf4j.LoggerFactory;
import
java.io.File
;
public
class
WebDriverUtil
{
//
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
WebDriverUtil
.
class
);
private
static
final
String
WINDOWS
=
"Windows"
;
...
...
@@ -40,12 +40,12 @@ public class WebDriverUtil {
case
Browser
.
FIREFOX
:
// /opt/apps/org.mozilla.firefox/files/lib/firefox-esr/firefox-esr
System
.
setProperty
(
"webdriver.firefox.driver"
,
WebDriverUtil
.
FIRE_FOX
+
executable
);
System
.
setProperty
(
"webdriver.firefox.bin"
,
"/home/hct/firefox/firefox"
);
//
System.setProperty("webdriver.firefox.bin", "/home/hct/firefox/firefox");
FirefoxOptions
firefoxOptions
=
new
FirefoxOptions
();
if
(
headless
)
{
firefoxOptions
.
addArguments
(
"--headless"
);
}
//
firefoxOptions.setBinary("/opt/apps/org.mozilla.firefox/files/lib/firefox-esr/firefox-esr");
firefoxOptions
.
setBinary
(
"/opt/apps/org.mozilla.firefox/files/lib/firefox-esr/firefox-esr"
);
return
new
FirefoxDriver
(
firefoxOptions
);
case
Browser
.
CHROME
:
System
.
setProperty
(
"webdriver.chrome.driver"
,
WebDriverUtil
.
CHROME
+
executable
);
...
...
@@ -80,7 +80,6 @@ public class WebDriverUtil {
default
:
throw
new
RuntimeException
(
"该浏览器不存在:"
+
browser
);
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论