Here mentioned code successfully passed by the test run.But it was not showed the login button click and the logged user name as well.Not print the messages which mentioned in the assertEquals as well.but result shows as passed.

I just wanted to why can't I see the button click and assertEqual messages?is there any coding issue or practice should be able to use to overcome this?

I have used the xml file to send the browser type.Further,I pasted only the relevant code sections.


public class TestCommands {
public void assertText(By locator,WebDriver driver,String expectedValue){
    try {
        WebElement element = driver.findElement(locator);
        assertEquals(element.getText(), expectedValue);         
    } catch (Exception e) {
        // TODO: handle exception
        System.out.println("Not equal");
    System.out.println("captured web element: "+ locator);
    System.out.println("captured expectedValue: "+ expectedValue);


public class LoginPage extends TestCommands{
public void loginToApplication(WebDriver driver,String userName,String  password,String loggedUser){



public class TC_LoginToTest {
WebDriver driver ;
String baseUrl;
LoginPage login = new LoginPage(); 

public void beforeMethod(String browser) {

    if (browser.equals("firefox")) {
        System.setProperty("webdriver.gecko.driver", "drivers\\geckodriver.exe");
        driver = new FirefoxDriver();
        //baseUrl = "https://test.com";
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    } else if (browser.equals("chrome")) {
        System.setProperty("webdriver.chrome.driver", "drivers\\chromedriver.exe");
        driver = new ChromeDriver();
        //baseUrl = "https://test.com";
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
public Object[][] tc001() {
    return new Object[][] {
            new Object[] {"nadee","12345678","Testnadee"},      

public void tc001(String userName , String password ,String loggedUser) {
    login.openApplication("https://test.com", driver);
    login.loginToApplication(driver, userName, password, loggedUser);
  • 1
    TestCommands:: assertText is not called anywhere. Additionally, " e.printStackTrace();f" is not a valid Java statement - it has an "extra" f. – João Farias Oct 9 at 11:25
  • I have made correction for that.But can't I use assertEquals to check the values?and also can I know the method to print it to the console as well? – user3806999 Oct 10 at 2:24

Your Answer

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

Browse other questions tagged or ask your own question.