Добрый день, коллеги!
Лирическое отступление
Не нужно меня спрашивать, зачем запускаются тесты из JAR файла,
когда есть ci-cd и даже тупо батники.
Это не моё желание, и знаю, что это не лучший выбор,
поэтому кто захочет - пишите просто по теме вопроса.
Что пробовал и что работало
При использовании более старых библиотек, версий:
selenide-testng 6.0.0
или по отдельности
selenide 5.23
testng 7.4
Проблем с запуском из скомпилированного JAR не было.
При попытке обновится на последние версии
(а ведь хочется использовать новые фишки селенида, зря чтоль дядя Андрей старается )
selenide-testng 6.10.1
или
или по отдельности
selenide 6.10.1
testng 7.6.1 (хотя в selenide-testng 6.10.1 всё ещё используется testng 7.4, и тут сравнение не точное )
Возникает ошибка, вида:
Error
java.lang.ExceptionInInitializerError
at org.openqa.selenium.remote.HttpCommandExecutor.getDefaultClientFactory(HttpCommandExecutor.java:62)
at org.openqa.selenium.remote.HttpCommandExecutor.(HttpCommandExecutor.java:87)
at org.openqa.selenium.remote.service.DriverCommandExecutor.(DriverCommandExecutor.java:80)
at org.openqa.selenium.chromium.ChromiumDriverCommandExecutor.(ChromiumDriverCommandExecutor.java:35)
at org.openqa.selenium.chrome.ChromeDriver$ChromeDriverCommandExecutor.(ChromeDriver.java:93)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:81)
at com.codeborne.selenide.webdriver.ChromeDriverFactory.create(ChromeDriverFactory.java:42)
at com.codeborne.selenide.webdriver.WebDriverFactory.createWebDriverInstance(WebDriverFactory.java:119)
at com.codeborne.selenide.webdriver.WebDriverFactory.createWebDriver(WebDriverFactory.java:67)
at com.codeborne.selenide.drivercommands.CreateDriverCommand.lambda$createDriver$0(CreateDriverCommand.java:76)
at com.codeborne.selenide.logevents.SelenideLogger.get(SelenideLogger.java:166)
at com.codeborne.selenide.drivercommands.CreateDriverCommand.createDriver(CreateDriverCommand.java:52)
at com.codeborne.selenide.impl.WebDriverThreadLocalContainer.createDriver(WebDriverThreadLocalContainer.java:180)
at com.codeborne.selenide.impl.WebDriverThreadLocalContainer.getAndCheckWebDriver(WebDriverThreadLocalContainer.java:149)
at com.codeborne.selenide.WebDriverRunner.getAndCheckWebDriver(WebDriverRunner.java:130)
at com.codeborne.selenide.impl.StaticDriver.getAndCheckWebDriver(StaticDriver.java:65)
at com.codeborne.selenide.SelenideDriver.getAndCheckWebDriver(SelenideDriver.java:220)
at com.codeborne.selenide.drivercommands.Navigator.lambda$navigateTo$0(Navigator.java:72)
at com.codeborne.selenide.logevents.SelenideLogger.run(SelenideLogger.java:153)
at com.codeborne.selenide.drivercommands.Navigator.navigateTo(Navigator.java:70)
at com.codeborne.selenide.drivercommands.Navigator.open(Navigator.java:32)
at com.codeborne.selenide.SelenideDriver.open(SelenideDriver.java:101)
at com.codeborne.selenide.Selenide.open(Selenide.java:52)
at tests.Test001.method001(Test001.java:16)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:598)
at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:173)
at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:824)
at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:146)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.testng.TestRunner.privateRun(TestRunner.java:794)
at org.testng.TestRunner.run(TestRunner.java:596)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:377)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:371)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:332)
at org.testng.SuiteRunner.run(SuiteRunner.java:276)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1212)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1134)
at org.testng.TestNG.runSuites(TestNG.java:1063)
at org.testng.TestNG.run(TestNG.java:1031)
at runner.Run.main(Run.java:21)
Caused by: java.lang.IllegalArgumentException: Unknown HttpClient factory selenide-netty-client-factory
at org.openqa.selenium.remote.http.HttpClient$Factory.create(HttpClient.java:57)
at org.openqa.selenium.remote.http.HttpClient$Factory.createDefault(HttpClient.java:73)
at org.openqa.selenium.remote.HttpCommandExecutor$DefaultClientFactoryHolder.(HttpCommandExecutor.java:58)
… 50 more
===============================================
Test 1
Tests run: 1, Failures: 1, Skips: 0
===============================================
RegresTests
Total tests run: 1, Passes: 0, Failures: 1, Skips: 0
Exception in thread “main” java.lang.AssertionError: Couldn’t find resource: jquery.min.js
at org.testng.reporters.jq.Main.generateReport(Main.java:92)
at org.testng.TestNG.generateReports(TestNG.java:1093)
at org.testng.TestNG.run(TestNG.java:1036)
at runner.Run.main(Run.java:21)
Попытки гуглить
При самостоятельной попытке найти источник проблем, находил похожие посты, в которых говорилось,
что проблема в перекрёстых зависимостях. И нужно найти этото конфликт, но:
- Почему же тогда тесты нормально запускаются не из JAR файла
- mvn dependency:tree мне ничего не показал (или я слепой, простите)
dependency-tree
mvn dependency:tree
[INFO] Scanning for projects…
[INFO]
[INFO] ------------------------< com.study:jaropenfx >-------------------------
[INFO] Building jaropenfx 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] — maven-dependency-plugin:2.8:tree (default-cli) @ jaropenfx —
[INFO] com.study:jaropenfx:jar:0.0.1-SNAPSHOT
[INFO] ± com.codeborne:selenide-testng:jar:6.10.1:compile
[INFO] | ± org.seleniumhq.selenium:selenium-java:jar:4.6.0:compile
[INFO] | | ± org.seleniumhq.selenium:selenium-api:jar:4.6.0:compile
[INFO] | | ± org.seleniumhq.selenium:selenium-chrome-driver:jar:4.6.0:compile
[INFO] | | | ± com.google.auto.service:auto-service-annotations:jar:1.0.1:compile
[INFO] | | | ± com.google.auto.service:auto-service:jar:1.0.1:compile
[INFO] | | | | - com.google.auto:auto-common:jar:1.2:compile
[INFO] | | | ± org.seleniumhq.selenium:selenium-chromium-driver:jar:4.6.0:compile
[INFO] | | | - org.seleniumhq.selenium:selenium-json:jar:4.6.0:compile
[INFO] | | ± org.seleniumhq.selenium:selenium-devtools-v105:jar:4.6.0:compile
[INFO] | | ± org.seleniumhq.selenium:selenium-devtools-v106:jar:4.6.0:compile
[INFO] | | ± org.seleniumhq.selenium:selenium-devtools-v107:jar:4.6.0:compile
[INFO] | | ± org.seleniumhq.selenium:selenium-devtools-v85:jar:4.6.0:compile
[INFO] | | ± org.seleniumhq.selenium:selenium-edge-driver:jar:4.6.0:compile
[INFO] | | ± org.seleniumhq.selenium:selenium-firefox-driver:jar:4.6.0:compile
[INFO] | | ± org.seleniumhq.selenium:selenium-ie-driver:jar:4.6.0:compile
[INFO] | | ± org.seleniumhq.selenium:selenium-remote-driver:jar:4.6.0:compile
[INFO] | | | ± com.beust:jcommander:jar:1.82:compile
[INFO] | | | ± io.netty:netty-buffer:jar:4.1.84.Final:compile
[INFO] | | | ± io.netty:netty-codec-http:jar:4.1.84.Final:compile
[INFO] | | | | ± io.netty:netty-codec:jar:4.1.84.Final:compile
[INFO] | | | | - io.netty:netty-handler:jar:4.1.84.Final:compile
[INFO] | | | ± io.netty:netty-common:jar:4.1.84.Final:compile
[INFO] | | | ± io.netty:netty-transport-classes-epoll:jar:4.1.84.Final:compile
[INFO] | | | ± io.netty:netty-transport-classes-kqueue:jar:4.1.84.Final:compile
[INFO] | | | ± io.netty:netty-transport-native-epoll:jar:4.1.84.Final:linux-x86_64
[INFO] | | | ± io.netty:netty-transport-native-kqueue:jar:4.1.84.Final:osx-x86_64
[INFO] | | | ± io.netty:netty-transport-native-unix-common:jar:4.1.84.Final:compile
[INFO] | | | ± io.netty:netty-transport:jar:4.1.84.Final:compile
[INFO] | | | | - io.netty:netty-resolver:jar:4.1.84.Final:compile
[INFO] | | | ± io.opentelemetry:opentelemetry-api:jar:1.19.0:compile
[INFO] | | | ± io.opentelemetry:opentelemetry-context:jar:1.19.0:compile
[INFO] | | | ± io.opentelemetry:opentelemetry-exporter-logging:jar:1.19.0:compile
[INFO] | | | | ± io.opentelemetry:opentelemetry-sdk-metrics:jar:1.19.0:compile
[INFO] | | | | - io.opentelemetry:opentelemetry-sdk-logs:jar:1.19.0-alpha:compile
[INFO] | | | | - io.opentelemetry:opentelemetry-api-logs:jar:1.19.0-alpha:compile
[INFO] | | | ± io.opentelemetry:opentelemetry-sdk-common:jar:1.19.0:compile
[INFO] | | | ± io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi:jar:1.19.0:compile
[INFO] | | | ± io.opentelemetry:opentelemetry-sdk-extension-autoconfigure:jar:1.19.0-alpha:compile
[INFO] | | | | - io.opentelemetry:opentelemetry-exporter-common:jar:1.19.0:runtime
[INFO] | | | ± io.opentelemetry:opentelemetry-sdk-trace:jar:1.19.0:compile
[INFO] | | | ± io.opentelemetry:opentelemetry-sdk:jar:1.19.0:compile
[INFO] | | | ± io.opentelemetry:opentelemetry-semconv:jar:1.19.0-alpha:compile
[INFO] | | | ± io.ous:jtoml:jar:2.0.0:compile
[INFO] | | | ± net.bytebuddy:byte-buddy:jar:1.12.18:compile
[INFO] | | | ± org.apache.commons:commons-exec:jar:1.3:compile
[INFO] | | | ± org.asynchttpclient:async-http-client:jar:2.12.3:compile
[INFO] | | | | ± org.asynchttpclient:async-http-client-netty-utils:jar:2.12.3:compile
[INFO] | | | | ± io.netty:netty-codec-socks:jar:4.1.60.Final:compile
[INFO] | | | | ± io.netty:netty-handler-proxy:jar:4.1.60.Final:compile
[INFO] | | | | ± io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.60.Final:compile
[INFO] | | | | ± io.netty:netty-transport-native-kqueue:jar:osx-x86_64:4.1.60.Final:compile
[INFO] | | | | ± org.reactivestreams:reactive-streams:jar:1.0.3:compile
[INFO] | | | | ± com.typesafe.netty:netty-reactive-streams:jar:2.0.4:compile
[INFO] | | | | - com.sun.activation:jakarta.activation:jar:1.2.2:compile
[INFO] | | | ± org.seleniumhq.selenium:selenium-http:jar:4.6.0:compile
[INFO] | | | | - dev.failsafe:failsafe:jar:3.3.0:compile
[INFO] | | | - org.seleniumhq.selenium:selenium-manager:jar:4.6.0:compile
[INFO] | | ± org.seleniumhq.selenium:selenium-safari-driver:jar:4.6.0:compile
[INFO] | | - org.seleniumhq.selenium:selenium-support:jar:4.6.0:compile
[INFO] | ± com.codeborne:selenide:jar:6.10.1:compile
[INFO] | | - com.codeborne:selenide-core:jar:6.10.1:compile
[INFO] | | ± org.opentest4j:opentest4j:jar:1.2.0:compile
[INFO] | | ± io.github.bonigarcia:webdrivermanager:jar:5.3.1:compile
[INFO] | | | ± com.google.code.gson:gson:jar:2.10:compile
[INFO] | | | - org.brotli:dec:jar:0.1.2:compile
[INFO] | | ± org.apache.commons:commons-compress:jar:1.22:runtime
[INFO] | | - org.apache.httpcomponents.client5:httpclient5:jar:5.2:compile
[INFO] | | ± org.apache.httpcomponents.core5:httpcore5:jar:5.2:compile
[INFO] | | - org.apache.httpcomponents.core5:httpcore5-h2:jar:5.2:compile
[INFO] | ± org.testng:testng:jar:7.4.0:compile
[INFO] | ± com.google.guava:guava:jar:31.1-jre:compile
[INFO] | | ± com.google.guava:failureaccess:jar:1.0.1:compile
[INFO] | | ± com.google.guava:listenablefuture:jar:9999.0-empty-to-avoid-conflict-with-guava:compile
[INFO] | | ± com.google.code.findbugs:jsr305:jar:3.0.2:compile
[INFO] | | ± org.checkerframework:checker-qual:jar:3.12.0:compile
[INFO] | | ± com.google.errorprone:error_prone_annotations:jar:2.11.0:compile
[INFO] | | - com.google.j2objc:j2objc-annotations:jar:1.3:compile
[INFO] | ± org.apache.commons:commons-lang3:jar:3.12.0:compile
[INFO] | - commons-io:commons-io:jar:2.11.0:runtime
[INFO] ± io.qameta.allure:allure-testng:jar:2.18.1:compile
[INFO] | ± io.qameta.allure:allure-java-commons:jar:2.18.1:compile
[INFO] | | - io.qameta.allure:allure-model:jar:2.18.1:compile
[INFO] | - io.qameta.allure:allure-test-filter:jar:2.18.1:runtime
[INFO] ± log4j:log4j:jar:1.2.17:compile
[INFO] ± org.slf4j:slf4j-api:jar:1.7.30:compile
[INFO] - org.slf4j:slf4j-log4j12:jar:1.7.30:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.964 s
[INFO] Finished at: 2022-11-25T16:04:57+04:00
[INFO] --------------------------------------------
И вторая проблема с JAR (чтобы не плодить темы):
При попытке перехода со старой верии Log4j на новую Log4j2 (org.apache.logging.log4j)
Стала возникать проблема:
Error With Log4j
java.lang.ExceptionInInitializerError
at tests.Test001.method001(Test001.java:14)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:598)
at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:173)
at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:824)
at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:146)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.testng.TestRunner.privateRun(TestRunner.java:794)
at org.testng.TestRunner.run(TestRunner.java:596)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:377)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:371)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:332)
at org.testng.SuiteRunner.run(SuiteRunner.java:276)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1212)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1134)
at org.testng.TestNG.runSuites(TestNG.java:1063)
at org.testng.TestNG.run(TestNG.java:1031)
at runner.Run.main(Run.java:21)
Caused by: java.lang.UnsupportedOperationException: No class provided, and an appropriate one cannot be found.
at org.apache.logging.log4j.LogManager.callerClass(LogManager.java:573)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:598)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:585)
at listeners.Log.(Log.java:8)
… 27 more
Попытки гуглить
Нашёл похожие посты, где говорится, что нужно в проект добавить манифест файл с указанием опции
Изменения, которые не помогли
Файл
/src/main/resources/MAETA-INF/MANIFEST.MF
Содержимое
Multi-Release:true
Файл
pom.xml
Содержимое
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</archive>
<finalName>result.jar</finalName>
</configuration>
</plugin>
Могу расшарить проект на гите, если кому то будет так удобнее посмотреть и помочь.
Но может кто то видит причину и так.