I have pieced together a web crawler with Selenium that uses XPath to find elements. On the web page I'm scraping, there are two possible layouts that are loaded, depending on the content.
If I run my code on the wrong layout, I get the error: Message: Unable to locate element: {"method":"xpath","selector":
How can I create a try
/except
(or similar) that tries an alternative xpath, if the first xpath is not present? Or if none is present, continue on to the next section of code?