How can i verify any laravel default flash message in selenium? Whether it displayed or not after the execution ? I can't locate the flash message as it was showing after page load. Providing my controller code for flash message below...

enter image description here

\Session::flash('flash_message', 'Question paper ' .ucwords(strtolower($request->Title)). ' added successfully');
 \Session::flash('alert-class', 'success');
  • Why did you tag your question with PHP? Php builds your html page?
    – Alexey R.
    Commented Mar 14, 2019 at 11:19
  • Not for any particular reason..As my project was built by php-laravel ..that's why i mentioned the tag php there
    – Albin K S
    Commented Mar 14, 2019 at 11:28
  • I can't locate the flash message as it was showing after page load. Why is this a problem? Can you add some your code trials? I do not see any potential problem to catch flash message.
    – Alexey R.
    Commented Mar 14, 2019 at 11:34
  • i just added the inspect section above. The real problem which i am facing is, how can i verify the success flash message ? How can i locate this message in selenium?
    – Albin K S
    Commented Mar 14, 2019 at 11:40

1 Answer 1


As per your screen shot there is a pre-defined text that fills your flash message. So what you could do is to set up FluentWait object that would use ExpectedConditions.visibilityOfElementLocated(...).



Make sure you have configured reasonably small polling interval so that you will catch even fast flash messages.

Put that waiter right after the line that brings you to the page that loads that flash-message.

Details on how to use FLuentWait: https://stackoverflow.com/questions/48336948/how-to-use-built-in-expectedconditions-with-fluentwait

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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