Skip to content

Commit

Permalink
[BqvAC2FK] Update selenium dependencies (#3675) (#3729)
Browse files Browse the repository at this point in the history
* [BqvAC2FK] solve deps conflicts

* [BqvAC2FK] Update selenium dependencies (#3675)

* [BqvAC2FK] Update selenium dependencies

* Added skip if ChromeDriver is incompatible with Chrome version

* [BqvAC2FK] Forced mockito version

* [BqvAC2FK] removed ext. dep
  • Loading branch information
vga91 authored Aug 22, 2023
1 parent f7e3d18 commit 62351b3
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 18 deletions.
16 changes: 12 additions & 4 deletions extended/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,12 @@ dependencies {

compileOnly group: 'org.apache.poi', name: 'poi', version: '5.1.0'
compileOnly group: 'org.apache.poi', name: 'poi-ooxml', version: '5.1.0'
compileOnly group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.141.59', {
compileOnly group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '4.10.0', {
exclude group: 'com.google.guava', module: 'guava'
}
compileOnly group: 'io.github.bonigarcia', name: 'webdrivermanager', version: '5.4.0', {
exclude group: 'com.google.guava', module: 'guava'
}
compileOnly group: 'io.github.bonigarcia', name: 'webdrivermanager', version: '5.1.0'
compileOnly 'org.mongodb:mongodb-driver:3.2.2', {
exclude group: 'io.netty'
}
Expand All @@ -102,13 +104,18 @@ dependencies {
compileOnly group: 'com.sun.mail', name: 'javax.mail', version: '1.6.0'
compileOnly group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib-jdk8', version: '1.6.0'

compileOnly group: 'org.apache.parquet', name: 'parquet-hadoop', version: '1.13.1', withoutServers
// testImplementation analogous is not needed since is bundled via `test-utils` submodule
compileOnly group: 'org.apache.hadoop', name: 'hadoop-common', version: '3.1.0', withoutServers


// These dependencies affect the tests only, they will not be packaged in the resulting .jar
testImplementation project(':test-utils')
testImplementation project(':core')
testImplementation group: 'org.apache.poi', name: 'poi', version: '5.1.0'
testImplementation group: 'org.apache.poi', name: 'poi-ooxml', version: '5.1.0'
testImplementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.141.59'
testImplementation group: 'io.github.bonigarcia', name: 'webdrivermanager', version: '5.1.0'
testImplementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '4.10.0'
testImplementation group: 'io.github.bonigarcia', name: 'webdrivermanager', version: '5.4.0'
testImplementation group: 'com.github.stefanbirkner', name: 'system-rules', version: '1.19.0'
testImplementation group: 'com.amazonaws', name: 'aws-java-sdk-s3', version: '1.11.270'
testImplementation group: 'org.reflections', name: 'reflections', version: '0.9.12'
Expand All @@ -130,6 +137,7 @@ dependencies {
testImplementation group: 'com.sun.mail', name: 'javax.mail', version: '1.6.0'
testImplementation group: 'org.postgresql', name: 'postgresql', version: '42.1.4'
testImplementation group: 'org.zapodot', name: 'embedded-ldap-junit', version: '0.9.0'
testImplementation group: 'org.apache.parquet', name: 'parquet-hadoop', version: '1.13.1', withoutServers


configurations.all {
Expand Down
4 changes: 2 additions & 2 deletions extended/src/main/java/apoc/load/LoadHtmlBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static InputStream getChromeInputStream(String url, Map<String, String> q
setupWebDriverManager(WebDriverManager.chromedriver(), config);

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setHeadless(isHeadless);
chromeOptions.addArguments("--headless=new");
chromeOptions.setAcceptInsecureCerts(isAcceptInsecureCerts);
return getInputStreamWithBrowser(url, query, config, new ChromeDriver(chromeOptions));
}
Expand All @@ -35,7 +35,7 @@ public static InputStream getFirefoxInputStream(String url, Map<String, String>
setupWebDriverManager(WebDriverManager.firefoxdriver(), config);

FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setHeadless(isHeadless);
firefoxOptions.addArguments("-headless");
firefoxOptions.setAcceptInsecureCerts(isAcceptInsecureCerts);
return getInputStreamWithBrowser(url, query, config, new FirefoxDriver(firefoxOptions));
}
Expand Down
23 changes: 14 additions & 9 deletions extended/src/test/java/apoc/load/LoadHtmlTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Stream;

import static apoc.ApocConfig.APOC_IMPORT_FILE_ENABLED;
import static apoc.ApocConfig.apocConfig;
Expand Down Expand Up @@ -84,19 +85,19 @@ public void tearDown() {

@Test
public void testParseGeneratedJs() {
testCallGeneratedJsWithBrowser("FIREFOX");
testCallGeneratedJsWithBrowser("CHROME");
testCallGeneratedJsWithBrowser(FIREFOX);
testCallGeneratedJsWithBrowser(CHROME);
}

@Test
public void testParseGeneratedJsWrongConfigs() {
assertWrongConfig(INVALID_CONFIG_ERR,
assertWrongConfig(INVALID_CONFIG_ERR + "No enum constant io.github.bonigarcia.wdm.config.OperatingSystem.dunno",
map("browser", CHROME, "operatingSystem", "dunno"));

assertWrongConfig(INVALID_CONFIG_ERR,
assertWrongConfig(INVALID_CONFIG_ERR + "No enum constant io.github.bonigarcia.wdm.config.Architecture.dunno",
map("browser", FIREFOX, "architecture", "dunno"));

assertWrongConfig("Error HTTP 401 executing",
assertWrongConfig("Error HTTP 404 executing https://raw.githubusercontent.com/bonigarcia/webdrivermanager/master/docs/mirror/geckodriver",
map("browser", FIREFOX,
"gitHubToken", "12345",
"forceDownload", true));
Expand All @@ -107,8 +108,9 @@ private void assertWrongConfig(String msgError, Map<String, Object> config) {
testCall(db, "CALL apoc.load.html($url, $query, $config)",
map("url", URL_HTML_JS, "query", map("a", "a"), "config", config),
r -> fail("Should fails due to wrong configuration"));
} catch (RuntimeException e) {
assertTrue(e.getMessage().contains(msgError));
} catch (Exception e) {
String message = e.getMessage();
assertTrue("Current message is: " + message, message.contains(msgError));
}
}

Expand Down Expand Up @@ -497,7 +499,7 @@ private void testCallGeneratedJsWithBrowser(String browser) {
testCall(db, "CALL apoc.load.html($url,$query,$config)",
map("url", URL_HTML_JS,
"query", map("td", "td", "strong", "strong"),
"config", map("browser", browser, "driverVersion", "0.30.0")),
"config", map("browser", browser)),
result -> {
Map<String, Object> value = (Map<String, Object>) result.get("value");
List<Map<String, Object>> tdList = (List<Map<String, Object>>) value.get("td");
Expand All @@ -522,8 +524,11 @@ public static void skipIfBrowserNotPresentOrCompatible(Runnable runnable) {
runnable.run();
} catch (RuntimeException e) {
// The test don't fail if the current chrome/firefox version is incompatible or if the browser is not installed
Stream<String> notPresentOrIncompatible = Stream.of("cannot find Chrome binary", "Cannot find firefox binary",
"browser start-up failure",
"This version of ChromeDriver only supports Chrome version");
final String msg = e.getMessage();
if (!msg.contains("cannot find Chrome binary") && !msg.contains("Cannot find firefox binary")) {
if (notPresentOrIncompatible.noneMatch(msg::contains)) {
throw e;
}
}
Expand Down
7 changes: 4 additions & 3 deletions extra-dependencies/selenium/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ jar {
}

dependencies {
// currently we cannot update to the latest version due to guava minimum version required (31.0.1-jre)
implementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.141.59', {
implementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '4.10.0' , {
exclude group: 'com.google.guava', module: 'guava'
}
implementation group: 'io.github.bonigarcia', name: 'webdrivermanager', version: '5.4.0', {
exclude group: 'com.google.guava', module: 'guava'
}
implementation group: 'io.github.bonigarcia', name: 'webdrivermanager', version: '5.1.0'
}

0 comments on commit 62351b3

Please sign in to comment.