I am trying to get selenium set up to send out messages automatically and have not yet got around to check if the specific listing has already been sent a message. This causes selenium to give a NoSuchElementException because its looking for (By.XPATH, ('//span[contains(text(),"Message")]')) How can I have it skip these pages where the element doesn't exist?
message = driver.find_element(By.XPATH, ('//span[contains(text(),"Message")]'))
message.click()
Very small snippet that shows the code where the issue is.