My answer is not directly to your question. It is advice. You should not use try catch for logic realization. Program languages (Java, c#, python etc) have if ... else statements. And you can use them for your problem. not debugged code, simply for example if(slogin.passwordField1.Existed) { return slogin.passwordField1; } else { return slogin.passwordField2; } You can find how realize existed property in Internet (it is easy) and you will levelup you developer skills