Selenium Java UnsupportedCommandException неизвестная команда: session/9845d50a442f6c23dc498210a0d253d7/se/file во времяJAVA

Программисты JAVA общаются здесь
Anonymous
Selenium Java UnsupportedCommandException неизвестная команда: session/9845d50a442f6c23dc498210a0d253d7/se/file во время

Сообщение Anonymous »

Я использую версию Selenium: «4.12.1» и версию браузера 112. Но столкнулся с трудностями при загрузке файла. Я использую метод sendKeys для отправки пути к файлу для xpath //input[@type='file'].
Технические характеристики:
Я использую Google ChromeDriver версии 112 и Selenium версии 4.1
Код:

Код: Выделить всё

WebElement fileInput = driver.findElement(By.xpath("//input[@type='file']"));
String filePath = "/path/to/file.txt";
fileInput.sendKeys(filePath);
Трассировка стека:

Код: Выделить всё

org.openqa.selenium.UnsupportedCommandException: unknown command: unknown command: session / 9845 d50a442f6c23dc498210a0d253d7 / se / file
Build info: version: '4.12.1', revision: '8e34639b11' System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.215-181.850.amzn2int.x86_64', java.version: '17.0.11'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Command: [9845 d50a442f6c23dc498210a0d253d7, uploadFile {
file = UEsDBBQACAgIADtor1gAAAAAAAAAAAAAAAARAAAAYnVsa1NoaXBUZXN0Lnhsc3icuwNwZdHXJZ502LFtq2PbTse2bTvp2LZt27Zt2x07mUr6+9d8M/+aX03Nq1dPdc/aZ6219z2n9rtXRgIIGAkAHBwcgNWkSgXgvz0QAQAA1AWsrRwMrRy0FVxtDO01qV0sLSYSxn730cIJeRPfoDBRw}]
Capabilities {
acceptInsecureCerts: true,
browserName: chrome,
browserVersion: 112.0 .5615 .49,
chrome: {
chromedriverVersion: 112.0 .5615 .49(bd2a7bcb881c..., userDataDir: /tmp/.org.chromium.Chromium...
},
goog: chromeOptions: {
debuggerAddress: localhost: 46485
},
networkConnectionEnabled: false,
pageLoadStrategy: normal,
platformName: linux,
proxy: Proxy(),
setWindowRect: true,
strictFileInteractability: false,
timeouts: {
implicit: 0,
pageLoad: 300000,
script: 30000
},
unhandledPromptBehavior: dismiss and notify,
webauthn: extension: credBlob: true,
webauthn: extension: largeBlob: true,
webauthn: extension: minPinLength: true,
webauthn: extension: prf: true,
webauthn: virtualAuthenticators: true
}
Element: [
[RemoteWebDriver: chrome on linux(9845 d50a442f6c23dc498210a0d253d7)] - >  xpath: //div[@role='dialog']//input[@accept='.xlsx']]
Session ID: 9845 d50a442f6c23dc498210a0d253d
at java.base / jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base / jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java: 77)
at java.base / jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java: 45)
at java.base / java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java: 499)
at java.base / java.lang.reflect.Constructor.newInstance(Constructor.java: 480)
at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.createException(Unknown Source)
at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(Unknown Source)
at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(Unknown Source)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(Unknown Source)
at org.openqa.selenium.remote.RemoteWebDriver.execute(Unknown Source)
at org.openqa.selenium.remote.RemoteWebElement.execute(Unknown Source)
at org.openqa.selenium.remote.RemoteWebElement.upload(Unknown Source)
at java.base / java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java: 197)
at java.base / java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java: 1625)
at java.base / java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java: 509)
at java.base / java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java: 499)
at java.base / java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java: 921)
at java.base / java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java: 234)
at java.base / java.util.stream.ReferencePipeline.collect(ReferencePipeline.java: 682)
at org.openqa.selenium.remote.RemoteWebElement.sendKeys(Unknown Source)
Что я пробовал:
  • Я пытался использовать JavaScriptExecutor, чтобы сделать элемент видимым, но это не сработало, поскольку проблема связана с конечная точка, на которую fileupload отправляет запрос.
  • Наткнулся на этот пост. Ссылка, в которой предлагается переопределить команду UPLOAD_FILE, сделала это, но столкнулась с несколькими проблемами.


Подробнее здесь: https://stackoverflow.com/questions/787 ... 5d50a442f6

Вернуться в «JAVA»