Я практикую Selenium, следуя этому руководству и работая на этой странице. Я использую более позднюю версию Selenium (4.26), TestNG (7.10.2 и Java JDK (Java 23) с версией IntellJ Community.
Пока я следовал руководству, у меня есть замечая, что тест продолжает выдавать мне «Нет такого исключения элемента», когда я запускаю этот метод:
private By uploadButton= By.xpath("//*[@id='file-submit']");
public void clickUploadButton(){
WebElement button= driver.findElement(uploadButton);
button.click();
}
Прежде чем использовать XPath, я пробовал использовать id и класс, но ничего. Я даже использовал неявный способ, но ничего не изменилось.
Странно то, что если я попытаюсь использовать метод «isDisplayed» для элемента перед щелчком, это возвращает мне правду. Поэтому я не понимаю, почему во время теста этот элемент не был найден.
Весь код и ответ я разместил здесь:
public void clickUploadButton(){
WebElement button= driver.findElement(uploadButton);
System.out.println("the element is "+button.isDisplayed());
button.click();
}
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
nov 12, 2024 10:34:57 AM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
WARNING: Unable to find CDP implementation matching 130
nov 12, 2024 10:34:57 AM org.openqa.selenium.chromium.ChromiumDriver lambda$new$5
WARNING: Unable to find version of CDP to use for 130.0.6723.117. You may need to include a dependency on a specific version of the CDP using something similar to `org.seleniumhq.selenium:selenium-devtools-v86:4.26.0` where the version ("v86") matches the version of the chromium-based browser you're using and the version number of the artifact is the same as Selenium's.
the element is true
org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":".button"}
(Session info: chrome=130.0.6723.117)
For documentation on this error, please visit: https://www.selenium.dev/documentation/ ... -exception
Build info: version: '4.26.0', revision: '8ccf0219d7'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '23'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [86364529612327c68c95c4fba0a9bb2c, findElement {using=class name, value=button}]
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 130.0.6723.117, chrome: {chromedriverVersion: 130.0.6723.116 (6ac35f94ae3..., userDataDir: C:\Users\CARLOC~1\AppData\L...}, fedcm:accounts: true, goog:chromeOptions: {debuggerAddress: localhost:52980}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: windows, proxy: Proxy(), se:cdp: ws://localhost:52980/devtoo..., se:cdpVersion: 130.0.6723.117, 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}
Session ID: 86364529612327c68c95c4fba0a9bb2c
Подробнее здесь: https://stackoverflow.com/questions/791 ... lement-isd
Нормально ли, что Selenium выдает мне «NoSuchElementException», даже если element.isdisplayed возвращает мне true ⇐ JAVA
Программисты JAVA общаются здесь
1731406590
Anonymous
Я практикую Selenium, следуя этому руководству и работая на этой странице. Я использую более позднюю версию Selenium (4.26), TestNG (7.10.2 и Java JDK (Java 23) с версией IntellJ Community.
Пока я следовал руководству, у меня есть замечая, что тест продолжает выдавать мне «Нет такого исключения элемента», когда я запускаю этот метод:
private By uploadButton= By.xpath("//*[@id='file-submit']");
public void clickUploadButton(){
WebElement button= driver.findElement(uploadButton);
button.click();
}
Прежде чем использовать XPath, я пробовал использовать id и класс, но ничего. Я даже использовал неявный способ, но ничего не изменилось.
Странно то, что если я попытаюсь использовать метод «isDisplayed» для элемента [b]перед щелчком[/b], это возвращает мне правду. Поэтому я не понимаю, почему во время теста этот элемент не был найден.
Весь код и ответ я разместил здесь:
public void clickUploadButton(){
WebElement button= driver.findElement(uploadButton);
System.out.println("the element is "+button.isDisplayed());
button.click();
}
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
nov 12, 2024 10:34:57 AM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
WARNING: Unable to find CDP implementation matching 130
nov 12, 2024 10:34:57 AM org.openqa.selenium.chromium.ChromiumDriver lambda$new$5
WARNING: Unable to find version of CDP to use for 130.0.6723.117. You may need to include a dependency on a specific version of the CDP using something similar to `org.seleniumhq.selenium:selenium-devtools-v86:4.26.0` where the version ("v86") matches the version of the chromium-based browser you're using and the version number of the artifact is the same as Selenium's.
the element is true
org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":".button"}
(Session info: chrome=130.0.6723.117)
For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
Build info: version: '4.26.0', revision: '8ccf0219d7'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '23'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [86364529612327c68c95c4fba0a9bb2c, findElement {using=class name, value=button}]
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 130.0.6723.117, chrome: {chromedriverVersion: 130.0.6723.116 (6ac35f94ae3..., userDataDir: C:\Users\CARLOC~1\AppData\L...}, fedcm:accounts: true, goog:chromeOptions: {debuggerAddress: localhost:52980}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: windows, proxy: Proxy(), se:cdp: ws://localhost:52980/devtoo..., se:cdpVersion: 130.0.6723.117, 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}
Session ID: 86364529612327c68c95c4fba0a9bb2c
Подробнее здесь: [url]https://stackoverflow.com/questions/79180460/is-it-normal-that-selenium-gives-me-nosuchelementexception-even-if-element-isd[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия