Skip to content

Commit

Permalink
1. translate.api 中的 chrome.path 相关配置,增加 {this} 可标识当前目录
Browse files Browse the repository at this point in the history
2. 对 chrome 相关配置增加未设置的判断,如果未设置,给出友好提示
  • Loading branch information
xnx3 committed Oct 16, 2023
1 parent e9eff81 commit cf03c87
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

import com.beust.jcommander.internal.Console;
import com.xnx3.BaseVO;
import com.xnx3.DateUtil;
import com.xnx3.FileUtil;
Expand All @@ -33,16 +35,28 @@ public class ChromeUtil {
private ChromeDriver driver;
static Map<String, String> headers;

//这俩在application.properties配置
//这俩在application.properties配置. 支持 {this} 标识当前路径,会替换为如: E:\abc\
static String chromePath;
static String chromeDriverPath;

public static String translateJs = "var console={ log:function(str){ var consolelogDiv = document.createElement(\"div\");"
+ "consolelogDiv.className=\"translate_consoleLog ignore\"; consolelogDiv.style.display='none'; consolelogDiv.innerHTML = str; try{ document.getElementsByTagName('html')[0].appendChild(consolelogDiv); }catch (ce){ } } };";
public static String translateCoverJs = "";
static {

chromePath = ApplicationPropertiesUtil.getProperty("chrome.path");
chromeDriverPath=ApplicationPropertiesUtil.getProperty("chrome.driver.path");
if(chromePath == null) {
ConsoleUtil.error("application.properties not find : chrome.path");
}else {
chromePath.replaceAll("\\{this\\}", SystemUtil.getCurrentDir());
}
if(chromeDriverPath == null) {
ConsoleUtil.error("application.properties not find : chrome.driver.path");
}else {
chromeDriverPath.replaceAll("\\{this\\}", SystemUtil.getCurrentDir());
}

ConsoleUtil.info("chrome.path:"+chromePath);
ConsoleUtil.info("chrome.driver.path:"+chromeDriverPath);

Expand Down

0 comments on commit cf03c87

Please sign in to comment.