0

Below is my SAMPLE code in which i am trying to create a simple report using the Leanft in which i am getting on result xml file.

@Test
public void Google() throws Exception {
 Reporter.init();
    WebDriver driver = new FirefoxDriver();
    driver.get("https://www.google.com");
    Thread.sleep(4000);
   if( driver.getTitle().equalsIgnoreCase("google")){
       Reporter.reportEvent("test", "test",Status.Failed);
   }
Reporter.generateReport();
driver.quit();
} 

2 Answers2

0

I see nothing wrong with your code as the report generates as you told it too.

However, I believe you were wanting something more like this to show that it PASSES when it finds the Google title:

@Test
public void Google() throws Exception {
    Reporter.init();
    WebDriver driver = new FirefoxDriver();
    driver.get("https://www.google.com");
    Thread.sleep(4000);
    if( driver.getTitle().equalsIgnoreCase("google")){
        Reporter.reportEvent("test", "test",Status.Passed);
    } else {
        Reporter.reportEvent("test","test",Status.Failed);
    }
    Reporter.generateReport();
    driver.quit();
}
0

As specified in the docs, if you're going to use a custom framework you'll also need to initialize the SDK (SDK.init() and SDK.cleanup())

E.G.

public static void main(String [] args){
    // initialize the SDK and report only once per process
    try{
        ModifiableSDKConfiguration config = new ModifiableSDKConfiguration();
        config.setServerAddress(new URI("ws://myServerAddress:5095"));
        SDK.init(config);
        Reporter.init();

        //put your test code here.

        //Generate the report and cleanup the SDK usage.
        Reporter.generateReport();
        SDK.cleanup();
    }  catch(Exception e){
    }
}
Adelin
  • 7,809
  • 5
  • 37
  • 65