Selenide аналог метода RemoteWebDriver.setFileDetector(new LocalFileDetector())

Всем привет! Для загрузки файла использую

WebDriver driver = new RemoteWebDriver(new URI("http://" + HOST_HUB + ":4444/wd/hub").toURL(), capabilities);
driver.setFileDetector(new LocalFileDetector());

Если первую строчку можно заменить на

Configuretion.remote = "http://" + HOST_HUB + ":4444/wd/hub";
Configuration.browserCapabilities = capabilities;

То как можно заменить вторую строчку?

driver.setFileDetector(new LocalFileDetector());

А вторая строчка не нужна, селенид это и так делает по умолчанию.

1 лайк

Да действительно! Спасибо)

Ещё вопрос по proxy

Сделал, как описано тут

Но тесты даже не запускаются, сразу пишут

Ошибки
unknown error: net::ERR_PROXY_CONNECTION_FAILED
  (Session info: chrome=88.0.4324.96)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'devops', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '5.4.0-72-generic', java.version: '1.8.0_292'
selenide.remote: http://10.10.199.45:4444/wd/hub
Driver info: org.openqa.selenium.remote.RemoteWebDriver
selenide.url: https://testing2.ros.chat:1110/
Capabilities {acceptInsecureCerts: true, browserName: chrome, browserVersion: 88.0.4324.96, chrome: {chromedriverVersion: 88.0.4324.27 (6347fe8bf1e48..., userDataDir: /tmp/.com.google.Chrome.iwj5W5}, goog:chromeOptions: {debuggerAddress: localhost:46465}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: LINUX, platformName: LINUX, proxy: Proxy(manual, http=localhos..., setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
selenide.baseUrl: https://testing2.ros.chat:1110
Session ID: 1962d652bf50dc3b8be8e9ce7c08c9cf
org.openqa.selenium.WebDriverException: unknown error: net::ERR_PROXY_CONNECTION_FAILED
  (Session info: chrome=88.0.4324.96)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'devops', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '5.4.0-72-generic', java.version: '1.8.0_292'
selenide.remote: http://10.10.199.45:4444/wd/hub
Driver info: org.openqa.selenium.remote.RemoteWebDriver
selenide.url: https://testing2.ros.chat:1110/
Capabilities {acceptInsecureCerts: true, browserName: chrome, browserVersion: 88.0.4324.96, chrome: {chromedriverVersion: 88.0.4324.27 (6347fe8bf1e48..., userDataDir: /tmp/.com.google.Chrome.iwj5W5}, goog:chromeOptions: {debuggerAddress: localhost:46465}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: LINUX, platformName: LINUX, proxy: Proxy(manual, http=localhos..., setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
selenide.baseUrl: https://testing2.ros.chat:1110
Session ID: 1962d652bf50dc3b8be8e9ce7c08c9cf
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
	at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:277)
	at org.openqa.selenium.remote.RemoteWebDriver$RemoteNavigation.to(RemoteWebDriver.java:857)
	at com.codeborne.selenide.drivercommands.Navigator.lambda$navigateTo$0(Navigator.java:70)
	at com.codeborne.selenide.logevents.SelenideLogger.run(SelenideLogger.java:139)
	at com.codeborne.selenide.drivercommands.Navigator.navigateTo(Navigator.java:66)
	at com.codeborne.selenide.drivercommands.Navigator.open(Navigator.java:30)
	at com.codeborne.selenide.SelenideDriver.open(SelenideDriver.java:86)
	at com.codeborne.selenide.Selenide.open(Selenide.java:49)
	at chat.ros.testing2.TestsBase.openMS(TestsBase.java:103)
	at chat.ros.testing2.ResourcesTests.beforeEach(ResourcesTests.java:134)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeEachCallbacks$1(TestMethodTestDescriptor.java:154)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeMethodsOrCallbacksUntilExceptionOccurs$5(TestMethodTestDescriptor.java:190)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeMethodsOrCallbacksUntilExceptionOccurs(TestMethodTestDescriptor.java:190)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeEachCallbacks(TestMethodTestDescriptor.java:153)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:131)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:71)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
	at java.util.ArrayList.forEach(ArrayList.java:1259)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
	at java.util.ArrayList.forEach(ArrayList.java:1259)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:87)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:53)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:66)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:51)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:87)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:66)
	at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:102)
	at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:82)
	at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:78)
	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:61)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
	at com.sun.proxy.$Proxy2.stop(Unknown Source)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.stop(TestWorker.java:132)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:175)
	at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:157)
	at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
	at java.lang.Thread.run(Thread.java:748)

Зависимости

implementation group: 'com.browserup', name: 'browserup-proxy-core', version: '2.1.2'
implementation group: 'io.netty', name: 'netty-codec', version: '4.1.63.Final'
implementation group: 'io.netty', name: 'netty-all', version: '4.1.63.Final'
Код
Configuration.proxyHost = "localhost";
        Configuration.remote = "http://" + HOST_HUB + ":4444/wd/hub";
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setBrowserName("chrome");
        capabilities.setVersion("88.0");
        capabilities.setCapability("enableVNC", true);
        capabilities.setCapability("enableVideo", false);
        capabilities.setCapability("acceptInsecureCerts", true);

        LoggingPreferences logPrefs = new LoggingPreferences();
        logPrefs.enable(LogType.PERFORMANCE, Level.ALL);
        capabilities.setCapability("goog:loggingPrefs", logPrefs);
        Configuration.browserCapabilities = capabilities;        
        Configuration.fileDownload = FileDownloadMode.PROXY;
        Configuration.proxyEnabled = true;
        Configuration.screenshots = false;

Если выполнить dependecies, то получаю кучу зависимостей. Нужно ли их все прописывать? Или достаточно тех, что указаны в примере?

Зависимости
+--- com.browserup:browserup-proxy-core:2.1.2
|    +--- io.netty:netty-codec:4.1.50.Final -> 4.1.63.Final
|    |    +--- io.netty:netty-common:4.1.63.Final
|    |    +--- io.netty:netty-buffer:4.1.63.Final
|    |    |    \--- io.netty:netty-common:4.1.63.Final
|    |    \--- io.netty:netty-transport:4.1.63.Final
|    |         +--- io.netty:netty-common:4.1.63.Final
|    |         +--- io.netty:netty-buffer:4.1.63.Final (*)
|    |         \--- io.netty:netty-resolver:4.1.63.Final
|    |              \--- io.netty:netty-common:4.1.63.Final
|    +--- xyz.rogfam:littleproxy:2.0.0-beta-5
|    |    +--- com.google.guava:guava:27.1-jre -> 30.1.1-jre (*)
|    |    +--- org.apache.commons:commons-lang3:3.8.1 -> 3.12.0
|    |    +--- com.barchart.udt:barchart-udt-bundle:2.3.0
|    |    \--- org.slf4j:slf4j-api:1.7.26 -> 2.0.0-alpha1
|    +--- com.browserup:browserup-proxy-mitm:2.1.2
|    |    +--- com.google.guava:guava:28.2-jre -> 30.1.1-jre (*)
|    |    +--- org.bouncycastle:bcpkix-jdk15on:1.64
|    |    |    \--- org.bouncycastle:bcprov-jdk15on:1.64
|    |    +--- org.bouncycastle:bcprov-jdk15on:1.64
|    |    +--- io.netty:netty-all:4.1.50.Final -> 4.1.63.Final
|    |    +--- io.netty:netty-codec:4.1.50.Final -> 4.1.63.Final (*)
|    |    +--- org.slf4j:jcl-over-slf4j:1.7.30
|    |    |    \--- org.slf4j:slf4j-api:1.7.30 -> 2.0.0-alpha1
|    |    +--- org.slf4j:slf4j-api:1.7.30 -> 2.0.0-alpha1
|    |    \--- xyz.rogfam:littleproxy:2.0.0-beta-5 (*)
|    +--- javax.xml.bind:jaxb-api:2.3.1
|    |    \--- javax.activation:javax.activation-api:1.2.0
|    +--- com.fasterxml.jackson.core:jackson-core:2.10.3
|    +--- com.fasterxml.jackson.core:jackson-databind:2.10.3 (*)
|    +--- com.fasterxml.jackson.core:jackson-annotations:2.10.3
|    +--- com.google.guava:guava:28.2-jre -> 30.1.1-jre (*)
|    +--- com.jcraft:jzlib:1.1.3
|    +--- dnsjava:dnsjava:3.1.0
|    |    \--- org.slf4j:slf4j-api:1.7.30 -> 2.0.0-alpha1
|    +--- io.netty:netty-all:4.1.50.Final -> 4.1.63.Final
|    +--- org.bouncycastle:bcpkix-jdk15on:1.64 (*)
|    +--- org.bouncycastle:bcprov-jdk15on:1.64
|    +--- org.brotli:dec:0.1.2
|    +--- org.javassist:javassist:3.27.0-GA
|    +--- org.seleniumhq.selenium:selenium-api:3.141.59
|    +--- org.slf4j:jcl-over-slf4j:1.7.30 (*)
|    \--- org.slf4j:slf4j-api:1.7.30 -> 2.0.0-alpha1
+--- io.netty:netty-codec:4.1.63.Final (*)
+--- io.netty:netty-all:4.1.63.Final

Нет, добавлять все зависимости не надо. Этим занимается Gradle.

А прокси может не работать и не только из-за конфликта зависимостей.
Возможно, с машины грида тупо нет доступа к вашей машине. Тогда прокси не может работать в принципе.

всем привет!
задача - зааплоадить файл в инпут поле.
Использую метод

File fileToUpload = new File( "src/test/resources/attachment.jpeg");
 getInputFieldForUploadFile().uploadFile(fileToUpload);

При ране локально - все отлично работает.
При ране на ремоут машине -


Где может быть проблема? Заранее спасибо.
<selenide.version>6.11.0</selenide.version>
<java.version>17</java.version>
<cucumber.version>7.0.0</cucumber.version>

Скорее всего, вы сами создаёте инстанс вебдрайвера. И поэтому вам нужно вызывать метод driver.setFileDetector(new LocalFileDetector());

Когда драйвер создаётся селенидом, он и так вызывает этот метод по умолчанию.

2 лайка