All Downloads are FREE. Search and download functionalities are using the official Maven repository.

utils.Helper Maven / Gradle / Ivy

Go to download

A OyoTestLibs jar for deployment to the Central Repository via OSSRH

The newest version!
package com.oyo.utils;

import java.io.File;
import java.io.IOException;
import java.util.Date;

public class Helper {

	
	public String getTestClassName(String testName) {
		String[] reqTestClassname = testName.split("\\.");
		int i = reqTestClassname.length - 1;
		return reqTestClassname[i];
	}
	
	//TODO: resolve the flow with ProjectName and driver and then uncomment this function
	public void takeScreenShot(String testClassName, String testMethodName) {

		/*// getting current date and time into string Ex: Thu Feb 18 18:13:38 IST
		// 2016
		Date currentDate = new Date();
		String currentDateAndTime = currentDate.toString();

		// splitting the date string Ex: "Thu Feb 18 18" out of "Thu Feb 18
		// 18:13:38 IST 2016"
		String[] dateFolder = currentDateAndTime.split(":");
		System.out.println(driver.getCurrentUrl());
		System.out.println();
		String newFolderName = filePathScreenShot + fileSeperator + dateFolder[0] + fileSeperator;

		File targetFolder = new File(newFolderName);
		if (!targetFolder.exists()) {
			// System.out.println("File created " + targetFolder);
			targetFolder.mkdir();
		}

		// taking screenshot
		File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);

		// adding test class name before the test method while creating
		// screenshot file
		File targetFile = new File(newFolderName + testClassName + "_" + testMethodName + ".png");

		// The below method will save the screen shot with test class and method
		// name
		try {
			FileUtils.copyFile(scrFile, targetFile);
		} catch (IOException e) {
			e.printStackTrace();
		}*/
	}
	
	public void alertUsers(String alertMessage) throws Exception {
		//sendSMStoAll(alertMessage);
		// makeCall();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy