Ad Home

Theme images by kelvinjay. Powered by Blogger.

Travel

Header Ads

Java

Selenium

UFT

Framework

General QA Concept

BDD

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

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..
driver.findElement(By.xpath("//body")).sendKeys(Keys.F5);


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
driver.navigate().refresh();


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

Actions actionObject = new Actions(driver);
actionObject.keyDown(Keys.CONTROL).sendKeys(Keys.F5).perform();


Hope that helps.

«
Next
Newer Post
»
Previous
Older Post

1 comments:

  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!

    ReplyDelete