cancel
Showing results for 
Search instead for 
Did you mean: 

Logging Selenium Tests in ReadyAPI

SOLVED
New Contributor

Logging Selenium Tests in ReadyAPI

I'm currently having the following problem:

 

I used ReadyAPI to make a testframework for testing backend. Now I made a Selenium Framework for testing the frontend.

I build a JAR from this Selenium framework so I could run these tests in the ReadyAPI framework.

 

I also put logging functionality in the Selenium framework (slf4j) that should generate a log file when the tests are run. This works when run seperately.
So far this doesn't happen when I'm running these tests from ReadyAPI.

 

Logging for the tests made in ReadyAPI is working fine.

 

So my question is:
The Selenium frontend tests run fine when run from the ReadyAPI framework, but there is no logging.
Does anyone have an idea how to solve this?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
New Contributor

Re: Logging Selenium Tests in ReadyAPI

I have a solution! Smartbear apparently uses log4j for logging. 

So you need to emplement this in your Selenium framework. 

 

Something like this:

package com.testproject.tests;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class TestClass{
    private Logger LOG;
	
    public TestClass(Logger LOG) {
        this.LOG = LOG;
    }

    public TestClass() {this(LogManager.getLogger(TestClass.class)); }

	@Test
    public void testMethod() {
        LOG.info("DEBUG LOGGING");
        LOG.debug("DEBUG LOGGING");
        LOG.warn("DEBUG LOGGING");
     }
}

Then you have to put some groovy in you ReadyAPI test to maken the test run and to get the logging:

//Imports
import com.testproject.tests.*;

//make sure to insert "log"
TestClass appt = new TestClass(log);
//driver is your webdriver and I left out the code to instantiate it
appt.setDriver(driver);
appt.testMethod();

Then you can adjust loglevels by adjusting "groovy.log" level in soapui-log4j.xml (wich will be in the bin folder of your ReadyAPI programfiles). In my original file it was set to "INFO". Here is an code example where I changed it to "DEBUG".

 

<logger name="groovy.log" level="DEBUG" additivity="false">
            <AppenderRef ref="CONSOLE"/>
            <AppenderRef ref="GLOBAL_GROOVY_LOG" level="DEBUG"/>
</logger>

Hope someone else can use this information aswell :-)

View solution in original post

3 REPLIES 3
Moderator

Re: Logging Selenium Tests in ReadyAPI

Thanks for reaching out, @Ploink!

 

As far as I can see in our DB, you have created a support ticket regarding this question. 

It would be great if you could share the results of the investigation with the Community when you have some.

Thank you in advance!


Olga Terentieva
SmartBear Assistant Community Manager

Highlighted
New Contributor

Re: Logging Selenium Tests in ReadyAPI

I have a solution! Smartbear apparently uses log4j for logging. 

So you need to emplement this in your Selenium framework. 

 

Something like this:

package com.testproject.tests;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class TestClass{
    private Logger LOG;
	
    public TestClass(Logger LOG) {
        this.LOG = LOG;
    }

    public TestClass() {this(LogManager.getLogger(TestClass.class)); }

	@Test
    public void testMethod() {
        LOG.info("DEBUG LOGGING");
        LOG.debug("DEBUG LOGGING");
        LOG.warn("DEBUG LOGGING");
     }
}

Then you have to put some groovy in you ReadyAPI test to maken the test run and to get the logging:

//Imports
import com.testproject.tests.*;

//make sure to insert "log"
TestClass appt = new TestClass(log);
//driver is your webdriver and I left out the code to instantiate it
appt.setDriver(driver);
appt.testMethod();

Then you can adjust loglevels by adjusting "groovy.log" level in soapui-log4j.xml (wich will be in the bin folder of your ReadyAPI programfiles). In my original file it was set to "INFO". Here is an code example where I changed it to "DEBUG".

 

<logger name="groovy.log" level="DEBUG" additivity="false">
            <AppenderRef ref="CONSOLE"/>
            <AppenderRef ref="GLOBAL_GROOVY_LOG" level="DEBUG"/>
</logger>

Hope someone else can use this information aswell :-)

View solution in original post

Moderator

Re: Logging Selenium Tests in ReadyAPI

Thank you so much for sharing, @PloinkSmiley Happy


Olga Terentieva
SmartBear Assistant Community Manager

New Here?
Join us and watch the welcome video:
Top Kudoed Authors