Assertion messages are not getting printed on console

524 views
Skip to first unread message

Jayshree

unread,
Jun 7, 2019, 3:48:35 AM6/7/19
to Selenium Users
Hi,

I have added assertion in my test cases Assert.asserttrue(true,"failed condition"), when my tcs failed I am not getting that message printed on console. Please help me 

raja nadar

unread,
Jun 7, 2019, 3:57:52 AM6/7/19
to seleniu...@googlegroups.com
Hi, 

Please share ur code and output screen so that we can see what the issue is. 

On Fri, 7 Jun, 2019, 1:18 PM Jayshree, <jayshr...@gmail.com> wrote:
Hi,

I have added assertion in my test cases Assert.asserttrue(true,"failed condition"), when my tcs failed I am not getting that message printed on console. Please help me 

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/3da2edef-f2df-4ff2-bce2-1fb895429b7e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jayshree

unread,
Jun 7, 2019, 5:01:49 AM6/7/19
to Selenium Users


Login Test:

public class LoginTest{
WebDriver driver;
 
@BeforeClass
     public void launchApplication() throws Exception
       {
          driver=Driver.getDriver();
        }
@Test
     public void loginToGmsrApplication() throws Exception {
     LoginBusiness loginBusiness= new LoginBusiness(driver);
      loginBusiness.loginToApplication();
      Assert.assertFalse(loginBusiness.loginToApplication(), "unable to enter username");
      

     } 
 
 
}

Login business:- 

public class LoginBusiness  {

private WebDriver driver;
LoginPage loginPage;
public LoginBusiness(WebDriver driver) throws Exception {
this.driver = driver;
loginPage = new LoginPage(driver);

}
public boolean loginToApplication() throws Exception {
loginPage.getUserNameTextField().clear();
Properties properties = Utility.getproperties(Constant.CONFIGURATION_PROPERTIES_FILE_PATH);
String username = properties.getProperty(Constant.USERNAME);
loginPage.getUserNameTextField().sendKeys(username);
String password = properties.getProperty(Constant.PASSWORD);
loginPage.getPasswordTextField().clear();
// ScreenshotUtility.captureScreenShot(driver);
loginPage.getPasswordTextField().sendKeys(password);
loginPage.getSignInButton().click();
return false;
}

}





On Friday, June 7, 2019 at 1:27:52 PM UTC+5:30, raja nadar wrote:
Hi, 

Please share ur code and output screen so that we can see what the issue is. 

On Fri, 7 Jun, 2019, 1:18 PM Jayshree, <jayshr...@gmail.com> wrote:
Hi,

I have added assertion in my test cases Assert.asserttrue(true,"failed condition"), when my tcs failed I am not getting that message printed on console. Please help me 

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to seleniu...@googlegroups.com.

Venu Adhi

unread,
Jun 7, 2019, 6:11:32 AM6/7/19
to Selenium Users
Assert.assertFalse(loginBusiness.loginToApplication(), "unable to enter username"); on this line you are expecting false, exactly this method "loginToApplication()" from loginBusiness page is returning false always because of this line in your script "return false;" in method loginToApplication(), So your assert will not print any message.

boolean myBlnFlag = false;
Assert.assertFalse(myBlnFlag, "this will print when myBlnFlag is true");   //this will not print log

boolean myBlnFlag = true;
Assert.assertFalse(myBlnFlag, "this will print when myBlnFlag is true");   // this will print our error msg

this will print when myBlnFlag is true

Jayshree

unread,
Jun 7, 2019, 7:07:36 AM6/7/19
to Selenium Users
I have added below lines of code in my test cases but its not working:

boolean myBlnFlag = true;
Assert.assertFalse(myBlnFlag, "this will print when myBlnFlag is true");   // this will print our error msg

public class LoginTest{
WebDriver driver;
 
@BeforeClass
     public void launchApplication() throws Exception
       {
          driver=Driver.getDriver();
        }
@Test
     public void loginToGmsrApplication() throws Exception {
     LoginBusiness loginBusiness= new LoginBusiness(driver);
      loginBusiness.loginToApplication();
      boolean myBlnFlag = true;
      Assert.assertFalse(myBlnFlag, "unsuccessful login");
     

     } 
 
 
}

no message is printing on console

Venu Adhi

unread,
Jun 7, 2019, 7:45:33 AM6/7/19
to Selenium Users
Can you add something like below and check what is in console

 @Test
     public void loginToGmsrApplication() throws Exception {
     LoginBusiness loginBusiness= new LoginBusiness(driver);
      loginBusiness.loginToApplication();
      boolean myBlnFlag = true;
      Assert.assertFalse(myBlnFlag, "unsuccessful login");
System.out.println("my assert is working");

Jayshree

unread,
Jun 7, 2019, 8:50:48 AM6/7/19
to Selenium Users


Its not printing written inside system.out.println();

raja nadar

unread,
Jun 7, 2019, 9:30:54 AM6/7/19
to seleniu...@googlegroups.com
Check whether your code is successfully running. If yes,  check the console output and testng output. 

To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.

To post to this group, send email to seleniu...@googlegroups.com.

Jayshree Braley

unread,
Jun 7, 2019, 2:26:44 PM6/7/19
to seleniu...@googlegroups.com
Sure, no message is displaying on console output, I will check for test output 

Reply all
Reply to author
Forward
0 new messages