Search code examples
testingseleniumweb-testing

Selenium + not able to verify action success using flash message


if(<webelement>.getText() == "Flash_Message_text")
    System.out.println(<message to be printed>);
else
    System.out.println(<webelement>.getText());
    waitFor(3000);

Once I perform an action and it is successful, then a flash message is displayed. As per the above code, I am identifying the flash message and using its text to verify if the action completed successfully or not.

However, it is never executing the "if" part of the code, and it is always printing from the "else" part.

Is there anything I am missing, or is there any other way I can handle this?


Solution

  • Try .equals() instead of == for String Comparison!