V
V
vadik_kmv2019-02-20 23:42:46
Java
vadik_kmv, 2019-02-20 23:42:46

How to form a screenshot name from a class name and a method?

Colleagues, hello!
Quite a little expert on TestNG, so the question arose: how to form the name of the screenshot file from the name of the class and the method that called it.
Listners are hardly suitable here, it is necessary at the time of the method run (say, there is already a makeScreenshot() method) to extract this data, but I don’t understand how yet.
Something like this:
@Test
public static void logIn() {
proceedToLoginPage();
populateCreds();
clickSubmit();
makeScreenshot(); // Take a screenshot after logging into the system, for example. I just don't fully understand how to get this data in the method
}
And there are many places where the method is used.
I would be very grateful for any advice.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
1
1001001, 2019-02-21
@1001001

System.out.println(this.getClass().getName());
        System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());

something like this, you can pull out the name of the method without problems only in before and after methodsmethod.getName();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question