I'd like to be able to see on-screen messages when my Chrome browser is running under Selenium, which will be useful to the human tester who occasionally monitors the execution manually. (The message would be a 1-liner saying "Testing Feature X...", "Feature X successful", .... etc.)

What is the best way to achieve this? Should I inject HTML on the page directly (which I'd like to avoid if possible)? Is it possible for me to send messages to the Chrome infobar which normally says "Chrome is being controlled by automated test software"? I'm using selenium's java driver 3.8.1 and chrome driver 2.33.506106.

  • You can render those messages on screen using swing and use showmessagedialog function – Amruta Pande Dec 10 '17 at 12:20
  • He may just look at the console by switching the window? Am I missing something? – Vishal Aggarwal Mar 10 '18 at 20:27
  • At console, you may display any helpful message as you want. – Vishal Aggarwal Mar 10 '18 at 20:28

Interesting idea.

Easiest would be to get OK for the idea from developers/web designer and to add a text input element in all your pages, which would NOT be used by tested system, but a placeholder for your information messages.

When you want to display a message to the tester, just locate this element and sendkeys message text to display it. Because tested system does not care about it, message will have no effect.

I would be against manipulating the HTML because I prefer to test the system as close to what will be deployed in production as possible. Having element for messages which tested system ignores in least disruptive.

For my tests, I just print such messages to the console, and also collect them in test object to be printed in test summary after all test finished running.


You can change the page title adding something like

((JavascriptExecutor)driver).executeScript("document.title = 'Test [" + testName + "]'");

This will not change page structure and won't introduce any risk of test page instability (unless you are testing the page title).

You will anyway need to use javascript to introduce your custom change to the document.

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.