From cf03c8724000b5cd9f6eadfc09a6bee33a42f7a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AC=BC=E7=94=BB=E7=AC=A6?= Date: Mon, 16 Oct 2023 10:03:55 +0800 Subject: [PATCH] =?UTF-8?q?1.=20translate.api=20=E4=B8=AD=E7=9A=84=20chrom?= =?UTF-8?q?e.path=20=E7=9B=B8=E5=85=B3=E9=85=8D=E7=BD=AE=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=20{this}=20=E5=8F=AF=E6=A0=87=E8=AF=86=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E7=9B=AE=E5=BD=95=202.=20=E5=AF=B9=20chrome=20?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E9=85=8D=E7=BD=AE=E5=A2=9E=E5=8A=A0=E6=9C=AA?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E7=9A=84=E5=88=A4=E6=96=AD=EF=BC=8C=E5=A6=82?= =?UTF-8?q?=E6=9E=9C=E6=9C=AA=E8=AE=BE=E7=BD=AE=EF=BC=8C=E7=BB=99=E5=87=BA?= =?UTF-8?q?=E5=8F=8B=E5=A5=BD=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zvo/translate/tcdn/api/util/ChromeUtil.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/translate.api/source/src/main/java/cn/zvo/translate/tcdn/api/util/ChromeUtil.java b/translate.api/source/src/main/java/cn/zvo/translate/tcdn/api/util/ChromeUtil.java index f329930..66a44ab 100644 --- a/translate.api/source/src/main/java/cn/zvo/translate/tcdn/api/util/ChromeUtil.java +++ b/translate.api/source/src/main/java/cn/zvo/translate/tcdn/api/util/ChromeUtil.java @@ -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; @@ -33,7 +35,7 @@ public class ChromeUtil { private ChromeDriver driver; static Map headers; - //这俩在application.properties配置 + //这俩在application.properties配置. 支持 {this} 标识当前路径,会替换为如: E:\abc\ static String chromePath; static String chromeDriverPath; @@ -41,8 +43,20 @@ public class ChromeUtil { + "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);