I'm trying to create an if statement with python selenium. I want if there is some element do something, but if there is no element pass, but it's not working.
I tried like this, but how do I write if this element is available continue, but if not pass.
if driver.find_element_by_name('selectAllCurrentMPNs'):
#follow some steps...
else:
pass
EDIT
It doesn't find element and crashes, but it should pass.
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: [name="selectAllCurrentMPNs"]
Stacktrace:
WebDriverError@chrome://remote/content/shared/webdriver/Errors.jsm:183:5
NoSuchElementError@chrome://remote/content/shared/webdriver/Errors.jsm:395:5
element.find/</<@chrome://remote/content/marionette/element.js:300:16
driver.find_element_by_name('selectAllCurrentMPNs')and quit whole process. In this case it should pass.