Search code examples
groovyautomated-testskatalon-studio

How to add an email with timestamp in a variable? Or is possible? (Katalon)


I want to use a custom Keyword like example:

public class alalbala {
    @Keyword
    def email(){

        String myEmailAddress = "test" + System.nanoTime() + "@itest.com";
        return myEmailAddress;
    }
}

And this myEmailAddress I want to check on another page like the example in a DB to see if this email is added. I am thinking to add in a variable and then using the variable to see if the email is present but I don't know-how. Can you help me, please!

Thank you in advance!


Solution

  • Let us say your alalbala class is inside of a package called myPackage.

    You need to import that class to the script you need to use. And then you can use your method (function) inside your script.

    For example:

    import static myPackage.alalbala.email
    
    def example = email()
    println example
    

    This will print something like "[email protected]", even though email method is declared in another file.