What is the defference between driver.navigate().refresh() and pressing F5?

December 22, 2013

I was going through a forum and found one of my mate tried to refresh a page after doing some operation in web. He used..

But this code was failing while running the code. I was googling for a suggestion or help and finally found one solution in stackoverflow..

Being interested , I observed all the possible causes and agreed the discussion there. The summary I found is as below:
It's not exactly equivalent to pressing F5 though. driver.navigate().refresh() in its request header says "no-cache" and, as a result, unconditionally reloads all content. Whereas pressing F5 could result in a "If-Modified-Since" request, that could get a "304 Not Modified" response.
Wow that is what I was looking for. Since this page is based on ajax so F5 was not working there. When I have used

It worked like a boom.
Also for pressing F5, we have one more option..

Actions actionObject = new Actions(driver);

Hope that helps.

You Might Also Like


  1. I signed up for several lessons (the 10 lessons package which was pretty good and signed up for few more additional lessons). Just took my driving test last Thursday and passed on my first try!