package com.friskysoft.test.framework;

import com.friskysoft.framework.Browser;
import com.friskysoft.test.pages.*;
import com.friskysoft.test.utils.ImageUploader;
import org.openqa.selenium.remote.BrowserType;
import org.testng.ITestResult;
import org.testng.annotations.*;
import org.testng.log4testng.Logger;

import java.net.URL;
import java.util.concurrent.TimeUnit;

public class BaseTests {

    protected Browser browser;
    protected String browserType = BrowserType.PHANTOMJS;
    protected String baseUrl = null;
    protected String loginPath = "/login.html";
    protected String homePath = "/home.html";
    protected String framesPath = "/frames.html";
    protected String overlapPath = "/overlap.html";
    protected String hoverPath = "/hover.html";

    protected HomePage homePage = new HomePage();
    protected LoginPage loginPage = new LoginPage();
    protected FramesPage framesPage = new FramesPage();
    protected OverlapPage overlapPage = new OverlapPage();
    protected HoverPage hoverPage = new HoverPage();

    protected Logger getLogger() {
        return Logger.getLogger(this.getClass());
    }

    @BeforeSuite
    public void setupLogger() {
        org.apache.log4j.BasicConfigurator.configure();
    }

    @BeforeClass
    public void setupBaseUrl() {
        URL resource = this.getClass().getResource("/test-web");
        baseUrl = "file://" + resource.getPath();
    }

    @BeforeClass
    public void setupBrowser() {
        browser = Browser.newLocalDriver(browserType)
                .setPageLoadTimeout(30, TimeUnit.SECONDS)
                .setImplicitWait(5, TimeUnit.SECONDS);
    }

    @AfterMethod
    public void failureScreenshot(ITestResult result) {
        if (result.getStatus() != ITestResult.SUCCESS) {
            try {
                String screenshot = browser.takeScreenshot();
                String screenshotUrl = ImageUploader.upload(screenshot);
                getLogger().error("Test failed! Screenshot uploaded at: " + screenshotUrl);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    }

    @AfterClass
    public void teardownBrowser() {
        browser.destroy();
    }

}

package com.friskysoft.test.framework;

import com.friskysoft.framework.Browser;
import com.friskysoft.test.pages.*;
import com.friskysoft.test.utils.ImageUploader;
import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.Level;
import org.apache.log4j.PatternLayout;
import org.openqa.selenium.remote.BrowserType;
import org.testng.ITestResult;
import org.testng.annotations.*;
import org.testng.log4testng.Logger;

import java.net.URL;
import java.util.concurrent.TimeUnit;

public class BaseTests {

    protected Browser browser;
    protected String browserType = BrowserType.PHANTOMJS;
    protected String baseUrl = null;
    protected String loginPath = "/login.html";
    protected String homePath = "/home.html";
    protected String framesPath = "/frames.html";
    protected String overlapPath = "/overlap.html";
    protected String hoverPath = "/hover.html";

    protected HomePage homePage = new HomePage();
    protected LoginPage loginPage = new LoginPage();
    protected FramesPage framesPage = new FramesPage();
    protected OverlapPage overlapPage = new OverlapPage();
    protected HoverPage hoverPage = new HoverPage();

    protected Logger getLogger() {
        return Logger.getLogger(this.getClass());
    }

    @BeforeSuite
    public void setupLogger() {
        org.apache.log4j.Logger.getRootLogger().setLevel(Level.INFO);
        org.apache.log4j.BasicConfigurator.configure();
    }

    @BeforeClass
    public void setupBaseUrl() {
        URL resource = this.getClass().getResource("/test-web");
        baseUrl = "file://" + resource.getPath();
    }

    @BeforeClass
    public void setupBrowser() {
        browser = Browser.newLocalDriver(browserType)
                .setPageLoadTimeout(30, TimeUnit.SECONDS)
                .setImplicitWait(5, TimeUnit.SECONDS);
    }

    @AfterMethod
    public void failureScreenshot(ITestResult result) {
        if (result.getStatus() != ITestResult.SUCCESS) {
            try {
                String screenshot = browser.takeScreenshot();
                String screenshotUrl = ImageUploader.upload(screenshot);
                getLogger().error("Test failed! Screenshot uploaded at: " + screenshotUrl);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    }

    @AfterClass
    public void teardownBrowser() {
        browser.destroy();
    }

}

set test log level to info