Ploink
6 years agoNew 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 Sele...
- 6 years ago
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 :-)