0

I have a sample program as follows

public static void enterText(WebElement loc, String value) {
    try {
        loc.clear();
        System.out.println("Text cleared successfully");
    } catch (Exception e) {
        // exception handling
    }
}

On executing loc.clear(), a runtime exception occurs. Is there a way I can get the method name with parameters after exception happens. I need to get this enterText(WebElement loc, String value).

1

2 Answers 2

0

You shall print the trace of the exception via this call: e.printStackTrace() inside catch block.

Sign up to request clarification or add additional context in comments.

2 Comments

No..that would not give me the argument details wit which the method was invoked.
@chinnuNish You can print the arguments in the catch block if you need
0

You just need to add a "print" statement in the catch block.

public static void enterText(WebElement loc, String value) {
    try {
        loc.clear();
        System.out.println("Text cleared successfully");
    }
    catch (Exception e) {
        System.out.printf("ERROR: enterText( %s , %s )%n", loc, value);
        e.printStackTrace();
    }
}

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.