2 years ago

#32630

test-img

Tadej Blatnik

How can I remove the backtrace from an error message when selenium can't find an element?

How can I remove the backtrace from an error message when selenium can't find an element?

Here is the sample code:

try:
  something = driver.find_element(By.CLASS_NAME, "button")
except:
  pass
  print(traceback.format_exc())

When the traceback is shown in the terminal due to the specified element not existing, there is a lot of information I would like to get rid of. In this case the Backtrace:

Traceback (most recent call last):

Backtrace:

    Ordinal0 [0x00D6FDC3+2555331]
    Ordinal0 [0x00D077F1+2127857]
    Ordinal0 [0x00C02E08+1060360]
    Ordinal0 [0x00C2E49E+1238174]
    Ordinal0 [0x00C2E69B+1238683]
    Ordinal0 [0x00C59252+1413714]
    Ordinal0 [0x00C47B54+1342292]
    Ordinal0 [0x00C575FA+1406458]
    Ordinal0 [0x00C47976+1341814]
    Ordinal0 [0x00C236B6+1193654]
    Ordinal0 [0x00C24546+1197382]
    GetHandleVerifier [0x00F09622+1619522]
    GetHandleVerifier [0x00FB882C+2336844]
    GetHandleVerifier [0x00E023E1+541697]
    GetHandleVerifier [0x00E01443+537699]
    Ordinal0 [0x00D0D18E+2150798]
    Ordinal0 [0x00D11518+2168088]
    Ordinal0 [0x00D11660+2168416]
    Ordinal0 [0x00D1B330+2208560]
    BaseThreadInitThunk [0x75C5FA29+25]
    RtlGetAppContainerNamedObjectPath [0x77677A9E+286]
    RtlGetAppContainerNamedObjectPath [0x77677A6E+238]

How do I delete the backtrace?

python

selenium

traceback

backtrace

0 Answers

Your Answer

Accepted video resources