0

I have generate TestNG report in eclipse to display results of fail/pass testcases, but in report it does not display which input string I had passed into textbox. So I want to display input string in the report. How can I show this in report?

package com.sevenbits.diecast;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.testng.Assert;
import org.testng.TestNGException;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

import com.beust.jcommander.Parameter;

public class LoginPage
{

    static WebDriver driver;

    String  expectedurl = "http://example/account-page/";

    final String userblank1 = " ";
    final String passblank1 = " ";

    String  userblank2  = "gffjghj";
    String  passblank2  = "";


    @BeforeClass
    public static void setup()throws TestNGException
    {
        System.setProperty("webdriver.chrome.driver", "E:\\Selenium Jar\\chromedriver.exe");
        ChromeOptions options = new ChromeOptions();
        options.addArguments("--disable-extensions");
        driver = new ChromeDriver(options);
        driver.manage().window().maximize();
    }

    @Test
    public void login()
    {
        driver.get("http://example.com");
        WebElement loginmain = driver.findElement(By.id("menu-item-14235"));
        loginmain.click();
    }


    @Test

    public void blankdata(String uname,String password)
    {
        driver.get("http://example.com");
        //driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);

        WebElement username = driver.findElement(By.name("log"));
        username.clear();
        username.sendKeys(userblank1);

        WebElement pass = driver.findElement(By.name("pwd"));
        pass.clear();
        pass.sendKeys(passblank1);

        WebElement submit = driver.findElement(By.name("Submit"));
        submit.click();

        String actual = driver.getCurrentUrl();

        Assert.assertEquals(expectedurl, actual);

    }

    @Test

    public void blankpassword(String uname,String password)
    {
        driver.get("http://example.com");
        //  driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);

        WebElement username = driver.findElement(By.name("log"));
        username.clear();
        username.sendKeys(userblank2);

        WebElement pass = driver.findElement(By.name("pwd"));
        pass.clear();
        pass.sendKeys(passblank2);

        WebElement submit = driver.findElement(By.name("Submit"));
        submit.click();

        String actual = driver.getCurrentUrl();

        Assert.assertEquals(expectedurl, actual);

    }
}

enter image description here

0

Using Data-provider annotation we can pass parameter and display it into report

@DataProvider(name = "Authentication")

      public static Object[][] credentials() {

            return new Object[][] { { "name", "pass"}};

      }
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.