I am trying to navigate the command on the alert box, but I am not able to do it in Web Driver with JAVA. Please help me with it. Apart from this I would also like to know how to tackle with the confirmation box and Warnings prompts displayed.
driver.switchTo().alert(); in Java. If you save the return value of that as an Alert object, you can interact with it, like
alert.accept(). See the javadoc for more information.
Since you're asking, however, I suspect it's not so simple. If this is not really an alert, but a popup that the browser has generated, such as a Basic Authentication prompt, you cannot interact with it using WebDriver, as WebDriver can only interact with things that exist in the DOM. You will have to use another Java library, such as Robot, to interact with popups at this level.
Look at the given link for example:
We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.