From 94efa622b4c151f0ef241c1dcfb291a5d3d4cf9d Mon Sep 17 00:00:00 2001 From: Motonori IWAMURO Date: Sun, 19 Mar 2023 22:49:12 +0900 Subject: [PATCH 1/3] catch up Selenium 4.8.1 and update dependency versions. --- RELEASENOTE.md | 5 ++++ pom.xml | 23 ++++++++----------- .../vmi/selenium/selenese/log/CookieMap.java | 1 - .../webdriver/ChromeDriverFactory.java | 5 ++-- .../webdriver/FirefoxDriverFactory.java | 8 +++---- .../jp/vmi/selenium/testutils/TestUtils.java | 3 ++- version-rules.xml | 5 ++++ 7 files changed, 28 insertions(+), 22 deletions(-) diff --git a/RELEASENOTE.md b/RELEASENOTE.md index bb134459c..eeb5fca2c 100644 --- a/RELEASENOTE.md +++ b/RELEASENOTE.md @@ -1,6 +1,11 @@ Selenese Runner Java Relase Note ================================ +### 4.3.0 + +* Catch up Selenium 4.8.1 and update dependency versions. + * Fix several problems associated with the update. + ### 4.2.0 * Catch up Selenium 4.4.0 and update dependency versions. diff --git a/pom.xml b/pom.xml index e9f08e2fd..97d5d4807 100644 --- a/pom.xml +++ b/pom.xml @@ -45,12 +45,12 @@ 1.8 1.8 true - 4.4.0 - 2.63.0 + 4.8.1 + 2.70.0 ${htmlunit.version} ${htmlunit.version} - 3.63.0 - 1.7.36 + 4.8.0 + 2.0.7 file://${basedir}/version-rules.xml src/shade/java target/shade-classes @@ -390,7 +390,7 @@ org.apache.ant ant-commons-net - 1.10.12 + 1.10.13 @@ -513,11 +513,6 @@ htmlunit-driver ${htmlunit-driver.version} - - io.netty - netty-all - 4.1.79.Final - com.google.guava guava @@ -573,7 +568,7 @@ ch.qos.logback logback-classic - 1.2.11 + 1.3.6 xalan @@ -593,12 +588,12 @@ com.floreysoft jmte - 7.0.0 + 7.0.2 com.google.code.gson gson - 2.9.1 + 2.10.1 junit @@ -664,7 +659,7 @@ org.glassfish.jaxb jaxb-runtime - 2.3.6 + 2.3.8 diff --git a/src/main/java/jp/vmi/selenium/selenese/log/CookieMap.java b/src/main/java/jp/vmi/selenium/selenese/log/CookieMap.java index 6743b6380..6f4a4c4f2 100644 --- a/src/main/java/jp/vmi/selenium/selenese/log/CookieMap.java +++ b/src/main/java/jp/vmi/selenium/selenese/log/CookieMap.java @@ -9,7 +9,6 @@ /** * Map of Cookies. */ -@SuppressWarnings("serial") public class CookieMap extends TreeMap { /** diff --git a/src/main/java/jp/vmi/selenium/webdriver/ChromeDriverFactory.java b/src/main/java/jp/vmi/selenium/webdriver/ChromeDriverFactory.java index 4a1662b6f..fa756b08f 100644 --- a/src/main/java/jp/vmi/selenium/webdriver/ChromeDriverFactory.java +++ b/src/main/java/jp/vmi/selenium/webdriver/ChromeDriverFactory.java @@ -41,8 +41,9 @@ public String getBrowserName() { */ public static ChromeOptions newChromeOptions(DriverOptions driverOptions) { ChromeOptions options = new ChromeOptions(); - if (driverOptions.has(HEADLESS)) - options.setHeadless(driverOptions.getBoolean(HEADLESS)); + options.addArguments("--remote-allow-origins=*"); // FIXME + if (driverOptions.has(HEADLESS) && driverOptions.getBoolean(HEADLESS)) + options.addArguments("--headless=new"); Proxy proxy = newProxy(driverOptions); if (proxy != null) options.setProxy(proxy); diff --git a/src/main/java/jp/vmi/selenium/webdriver/FirefoxDriverFactory.java b/src/main/java/jp/vmi/selenium/webdriver/FirefoxDriverFactory.java index c57483586..216611beb 100644 --- a/src/main/java/jp/vmi/selenium/webdriver/FirefoxDriverFactory.java +++ b/src/main/java/jp/vmi/selenium/webdriver/FirefoxDriverFactory.java @@ -44,8 +44,8 @@ public String getBrowserName() { */ public static FirefoxOptions newFirefoxOptions(DriverOptions driverOptions) { FirefoxOptions options = new FirefoxOptions(); - if (driverOptions.has(HEADLESS)) - options.setHeadless(driverOptions.getBoolean(HEADLESS)); + if (driverOptions.has(HEADLESS) && driverOptions.getBoolean(HEADLESS)) + options.addArguments("--headless"); Proxy proxy = newProxy(driverOptions); if (proxy != null) options.setProxy(proxy); @@ -79,7 +79,7 @@ public WebDriver newInstance(DriverOptions driverOptions) { public static void setDriverSpecificCapabilitiesForRemoteWebDriver(DesiredCapabilities caps, DriverOptions driverOptions) { String firefoxBin = getFirefoxBinary(driverOptions); if (firefoxBin != null) { - caps.setCapability(FirefoxDriver.Capability.BINARY, firefoxBin); + caps.setCapability(FirefoxDriver.SystemProperty.BROWSER_BINARY, firefoxBin); log.info("Firefox binary: {}", firefoxBin); } if (driverOptions.has(CLI_ARGS)) @@ -91,7 +91,7 @@ public static void setDriverSpecificCapabilitiesForRemoteWebDriver(DesiredCapabi setProxyConfiguration(profile, driverOptions); } if (profile != null) { - caps.setCapability(FirefoxDriver.Capability.PROFILE, profile); + caps.setCapability(FirefoxDriver.SystemProperty.BROWSER_PROFILE, profile); } } diff --git a/src/test/java/jp/vmi/selenium/testutils/TestUtils.java b/src/test/java/jp/vmi/selenium/testutils/TestUtils.java index 601737349..b16d32015 100644 --- a/src/test/java/jp/vmi/selenium/testutils/TestUtils.java +++ b/src/test/java/jp/vmi/selenium/testutils/TestUtils.java @@ -81,7 +81,8 @@ public static List getWebDriverFactories() { HTMLUNIT, FIREFOX, CHROME, - IE, + EDGE, + // IE, // SAFARI, // FIXME: On Selenium 2.46.0, SafariDriver does not work. }; } else { diff --git a/version-rules.xml b/version-rules.xml index f8c7adc7c..638f4a407 100644 --- a/version-rules.xml +++ b/version-rules.xml @@ -40,6 +40,11 @@ [3-9]\..+|\d\d.+|\d+(\.\d+)+-[bM][\d.]+|3\..+ + + + 1\.([4-9]|[0-9][0-9]).* + + .*-rc-\d+ From cf84fd11d2deff1868829a9fd6e6c49ad6f8c90c Mon Sep 17 00:00:00 2001 From: Motonori IWAMURO Date: Sun, 19 Mar 2023 22:57:03 +0900 Subject: [PATCH 2/3] remove dependency on `xalan` for security reason. (#337) --- RELEASENOTE.md | 1 + pom.xml | 5 -- .../parser/SeleneseCommandIterator.java | 1 - .../parser/SeleneseIteratorFactory.java | 1 - .../parser/SeleneseTestCaseIterator.java | 1 - .../selenium/selenese/parser/XPathAPI.java | 57 +++++++++++++++++++ 6 files changed, 58 insertions(+), 8 deletions(-) create mode 100644 src/main/java/jp/vmi/selenium/selenese/parser/XPathAPI.java diff --git a/RELEASENOTE.md b/RELEASENOTE.md index eeb5fca2c..f0a5023ad 100644 --- a/RELEASENOTE.md +++ b/RELEASENOTE.md @@ -5,6 +5,7 @@ Selenese Runner Java Relase Note * Catch up Selenium 4.8.1 and update dependency versions. * Fix several problems associated with the update. +* Remove dependency on `xalan` for security reason. (#337) ### 4.2.0 diff --git a/pom.xml b/pom.xml index 97d5d4807..a9500a240 100644 --- a/pom.xml +++ b/pom.xml @@ -570,11 +570,6 @@ logback-classic 1.3.6 - - xalan - xalan - 2.7.2 - com.google.inject guice diff --git a/src/main/java/jp/vmi/selenium/selenese/parser/SeleneseCommandIterator.java b/src/main/java/jp/vmi/selenium/selenese/parser/SeleneseCommandIterator.java index c450c7fd8..a757aa404 100644 --- a/src/main/java/jp/vmi/selenium/selenese/parser/SeleneseCommandIterator.java +++ b/src/main/java/jp/vmi/selenium/selenese/parser/SeleneseCommandIterator.java @@ -6,7 +6,6 @@ import javax.xml.transform.TransformerException; -import org.apache.xpath.XPathAPI; import org.w3c.dom.DOMException; import org.w3c.dom.Document; import org.w3c.dom.Node; diff --git a/src/main/java/jp/vmi/selenium/selenese/parser/SeleneseIteratorFactory.java b/src/main/java/jp/vmi/selenium/selenese/parser/SeleneseIteratorFactory.java index 8b1a913d3..5e15397c4 100644 --- a/src/main/java/jp/vmi/selenium/selenese/parser/SeleneseIteratorFactory.java +++ b/src/main/java/jp/vmi/selenium/selenese/parser/SeleneseIteratorFactory.java @@ -6,7 +6,6 @@ import javax.xml.transform.TransformerException; -import org.apache.xpath.XPathAPI; import org.cyberneko.html.parsers.DOMParser; import org.w3c.dom.Document; import org.w3c.dom.Node; diff --git a/src/main/java/jp/vmi/selenium/selenese/parser/SeleneseTestCaseIterator.java b/src/main/java/jp/vmi/selenium/selenese/parser/SeleneseTestCaseIterator.java index 6771b49d7..24d86c074 100644 --- a/src/main/java/jp/vmi/selenium/selenese/parser/SeleneseTestCaseIterator.java +++ b/src/main/java/jp/vmi/selenium/selenese/parser/SeleneseTestCaseIterator.java @@ -5,7 +5,6 @@ import javax.xml.transform.TransformerException; import org.apache.commons.io.FilenameUtils; -import org.apache.xpath.XPathAPI; import org.w3c.dom.Document; import org.w3c.dom.NodeList; diff --git a/src/main/java/jp/vmi/selenium/selenese/parser/XPathAPI.java b/src/main/java/jp/vmi/selenium/selenese/parser/XPathAPI.java new file mode 100644 index 000000000..5044e8616 --- /dev/null +++ b/src/main/java/jp/vmi/selenium/selenese/parser/XPathAPI.java @@ -0,0 +1,57 @@ +package jp.vmi.selenium.selenese.parser; + +import javax.xml.transform.TransformerException; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathExpression; +import javax.xml.xpath.XPathExpressionException; +import javax.xml.xpath.XPathFactory; + +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +/** + * org.apache.xpath.XPathAPI alternative. + */ +public class XPathAPI { + + /** + * Select single node. + * + * @param document XML document. + * @param query query + * @return node + * @throws TransformerException exception. + */ + public static Node selectSingleNode(Document document, String query) throws TransformerException { + XPathFactory f = XPathFactory.newInstance(); + XPath xPath = f.newXPath(); + try { + XPathExpression expr = xPath.compile(query); + return (Node) expr.evaluate(document, XPathConstants.NODE); + } catch (XPathExpressionException e) { + throw new TransformerException(e); + } + } + + /** + * Select node list. + * + * @param document XML document. + * @param query query + * @return list of node + * @throws TransformerException exception. + */ + public static NodeList selectNodeList(Document document, String query) throws TransformerException { + XPathFactory f = XPathFactory.newInstance(); + XPath xPath = f.newXPath(); + try { + XPathExpression expr = xPath.compile(query); + return (NodeList) expr.evaluate(document, XPathConstants.NODESET); + } catch (XPathExpressionException e) { + throw new TransformerException(e); + } + } + +} From ae17e48b468d927b2789546fae1668cec5dcf9ad Mon Sep 17 00:00:00 2001 From: Motonori IWAMURO Date: Tue, 21 Mar 2023 23:13:33 +0900 Subject: [PATCH 3/3] fix bugs in scripts on Cygwin. --- run.sh | 9 ++++++++- tools/classpath.sh | 7 ++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/run.sh b/run.sh index 47c48cadc..4d3dc548c 100755 --- a/run.sh +++ b/run.sh @@ -27,9 +27,16 @@ do_script() { local file="$1"; shift set -x case "$OSTYPE" in - linux*|cygwin*) + linux*) script -c "$*" "$file" ;; + cygwin*) + cmd="" + for a in "$@"; do + cmd="$cmd '$a'" + done + script -c "${cmd# }" "$file" + ;; darwin*|*bsd*) script "$file" "$@" ;; diff --git a/tools/classpath.sh b/tools/classpath.sh index 823f54cad..6379ab4a2 100755 --- a/tools/classpath.sh +++ b/tools/classpath.sh @@ -6,9 +6,13 @@ cd "$(dirname "$0")/.." # set classpath separator if [ "$OSTYPE" != "cygwin" ]; then + ps="/" sep=":" + pwd="$PWD" else + ps='\' sep=";" + pwd="$(cygpath -aw .)" fi # find MD5 sum command. @@ -26,6 +30,7 @@ if [ -z "$md5sum" ]; then fi # generate classpath from pom.xml. +mkdir -p tmp cp_conf="tmp/cp.conf" pom_xml_md5="tmp/pom.xml.md5" $md5sum pom.xml > "$pom_xml_md5.new" @@ -37,4 +42,4 @@ else mvn -Dmdep.outputFile="$cp_conf" dependency:build-classpath mv "$pom_xml_md5.new" "$pom_xml_md5" fi -echo "$PWD/target/classes${sep}$PWD/target/test-classes${sep}$(< "$cp_conf")" +echo "${pwd}${ps}target${ps}classes${sep}${pwd}${ps}target${ps}test-classes${sep}$(< "$cp_conf")"