Skip to content

Omniture Debugger: WebDriver based test changes

anandbagmar edited this page Jul 22, 2011 · 1 revision

Import relevant packages

/*
Import packages
*/
import com.thoughtworks.webanalyticsautomation.scriptrunner.WebDriverScriptRunner;
import com.thoughtworks.webanalyticsautomation.common.BROWSER;
import com.thoughtworks.webanalyticsautomation.inputdata.InputFileType;
import com.thoughtworks.webanalyticsautomation.plugins.WebAnalyticTool;
import static com.thoughtworks.webanalyticsautomation.Controller.getInstance;
import static com.thoughtworks.webanalyticsautomation.common.Utils.currentDirectory;
import static com.thoughtworks.webanalyticsautomation.common.Utils.fileSeparator;

Define & provide parameter values

/*
Define & provide parameter values
*/
private Engine engine;
private WebAnalyticTool webAnalyticTool = WebAnalyticTool.OMNITURE_DEBUGGER;
private InputFileType inputFileType = InputFileType.XML;
private boolean keepLoadedFileInMemory = true;
private String log4jPropertiesAbsoluteFilePath = currentDirectory() + fileSeparator() + "resources"  + fileSeparator() + "log4j.properties";
private String inputDataFileName = currentDirectory() + fileSeparator() + "test"  + fileSeparator() + "sampledata"  + fileSeparator() + "TestData.xml";
private String actionName = "OpenUpcomingPage_OmnitureDebugger_WebDriver";

Initialize Engine

/*
Initialize Engine
*/
engine = Controller.getInstance (webAnalyticTool, inputFileType, keepLoadedFileInMemory, log4jPropertiesAbsoluteFilePath);

Enable Web Analytics Testing

/*
Enable Web Analytics Testing
*/
engine.enableWebAnalyticsTesting();

Verify Web Analytics reporting using WAAT

/*
Verify Web Analytics Reporting using WAAT
*/
Result verificationResult = engine.verifyWebAnalyticsData (inputDataFileName, actionName, new WebDriverScriptRunner(driverInstance));

Sample Validations

/*
Sample validations
*/
assertNotNull(verificationResult.getVerificationStatus(), "Verification status should NOT be NULL");
assertNotNull(verificationResult.getListOfErrors(), "Failure details should NOT be NULL");
logVerificationErrors(verificationResult);
assertEquals(verificationResult.getVerificationStatus(), Status.PASS, "Verification status should be PASS");
assertEquals(verificationResult.getListOfErrors().size(), 0, "Failure details should be empty");

Disable Web Analytics reporting

/*
Disable Web Analytics Testing
*/
/* 
*	If using TestNG, override the @AfterMethod annotation
*	If using JUnit, override the @After annotation
*	and add the following line in it:
*		        engine.disableWebAnalyticsTesting();
*	See the example shown below
*/
@AfterMethod()
public void tearDown() throws Exception {
    engine.disableWebAnalyticsTesting();
    webDriverScriptRunnerHelper.stopDriver();
}