提交 29d2eb92 authored 作者: 黄承天's avatar 黄承天

[fix]

增加对输入参数的非空判断
上级 fa8a57cf
......@@ -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 {
}
}
}
}
/**
* 执行一个步骤
......
......@@ -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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论