How to handle NoSuchElement Exception in Java Selenium

preview_player
Показать описание
This video clearly explains how to handle nosuchelement exception in Java Selenium.

What is NoSuchElementException?
NoSuchElementException is one of the different WebDriver Exceptions and this Exception occurs, when the locators (i.e. id / XPath/ CSS selectors etc) we mentioned in the Selenium Program code is unable to find the web element on the web page.

Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 80.0.3987.100, chrome: {chromedriverVersion: 80.0.3987.16 (320f6526c1632..., userDataDir: C:\Users\HP\AppData\Local\T...}, goog:chromeOptions: {debuggerAddress: localhost:63065}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: 61056dca44101f06337724c9b9074e37
*** Element info: {Using=xpath, value=//div[.='Login']}
58)

Common Exceptions in Selenium WebDriver:
NoSuchElementException.
NoSuchWindowException.
NoSuchFrameException.
NoAlertPresentException.
InvalidSelectorException.
ElementNotVisibleException.
ElementNotSelectableException.
TimeoutException.

So I hope you guys have understood how do you resolve as no such element exception.
Login now to access all the courses designed by the experts of SkillRary.

For more info, visit Skillrary.

For regular updates on the latest courses and assessments or certifications,
Follow us on Facebook,

Follow us on Twitter,

Follow us on LinkedIn,

Follow us on Instagram,
Рекомендации по теме
Комментарии
Автор

Good work thanks for the tip to catch the error it resolved my problem with Nosuchelement

sajjadbaig
Автор

in amazon website i have written a correct xpath but still it is throwing no such element exeption

gowreeshk
Автор

Here we r not handling thenosuchelemen exception, it should be like if that specific elements are present sometimes and sometimes it's not present then script should work in both the cases

SourabhSingh-zxfh