I need to check in an HTML page if the "tr" exists, if the td does not exist that it condonue to execute the code and does not present an error for not having found, as it presents in the following image.

enter image description here

It is because in some pages there is [tr: nth-of-type (3)] and in other pages it does not exist.

1 Answer 1


First - please use code, do not put screenshots here :)

Easiest (but not fastest) way of solving this is:

    IWebElement nomeDoPortal2 = secondRow...
    // do something if exist
catch (Exception e) 
    // do something if it doesn't exist

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.