[Ironpython-users] Failing to catch exception
jdhardy at gmail.com
Thu May 7 12:41:49 CEST 2015
The first thing you should try is upgrading your IronPython to 2.7.5.
I believe there's a fix for exception handling in one of the newer
If not there might be something deeper and more annoying at play
(types getting loaded into different contexts that are not
On Wed, May 6, 2015 at 2:43 PM, <egroups at sowray.com> wrote:
> I'm probably doing something extremely stupid. I'm using Selenium to parse
> a web page, but can't catch the exceptions it throws:
> # Add Selenium
> from OpenQA.Selenium import *
> from OpenQA.Selenium.IE import *
> class MyWindow(Window):
> def __init__(self):
> # Initialize the Selenium object and open the page to parse
> self.driver = InternetExplorerDriver()
> def ParseStoryStandardFormat(self):
> parsed_ok = 1
> flagIndicator =
> fiUuid = syndicationIndicator.GetAttribute("data-uuid")
> except NoSuchElementException:
> parsed_ok = 0
> (The [...] in the code represents where I've edited out the irrelevant
> bits.) I'm using IronPython 220.127.116.11 on .NET 4.0.30319 from VS 2010 with
> the latest PTVS.
> If there's no flag-indicator class on the web page, the code stops at the
> first line of the try: and throws a NoSuchElementException. I've tried
> explicitly importing the exception (from OpenQA.Selenium import
> NoSuchElementException) and tried a catch-all "except:", but nothing seems
> to catch this error.
> If I run it from VS with debugging, it tells me the NoSuchElementException
> was unhandled by user code. If I run it without debugging, the application
> just crashes and terminates. To check other errors are handled, I added a
> try: xyz = 123 / 0 except: xyz = 0 at the beginning of the function and
> that was handled without any problem.
> If anybody can shed some light on what I'm doing wrong, I'd be very grateful.
> Ironpython-users mailing list
> Ironpython-users at python.org
More information about the Ironpython-users