Sometimes we need to refresh the web page to ensure that all the elements are loaded. In some of the cases we see that for the first attempt all elements are not loaded but if we load the page for the second time we see that all the components are loaded. Some of the cases we need to load pages more than one times. In that case we use some conditional loops until the components are loaded.
Using refresh() method:
Selenium webdriver has a method called refresh(). This is widely used command. It refreshes the current page after executing.
Using sendkeys() method:
sendkeys() method is used like we do page refresh pressing F5 key through our keyboard. This manual task is executed by code using the sendkeys() command over an element.
The command will be like
Using navigate().to() method:
Actually browsing the same URL using navigate().to() function. We call getCurrentUrl() function to get the current URL of the page.
Using get() method:
If we know the URL then we can load the same URL again to reload the page. In Java,
We can also use getCurrentUrl() function to know the current URL of the page. The command would be,
Using sendkeys() method with ASCII code:
We can use ASCII code as argument on sendkeys() method that is equivalent to F5 key command of the keyboard.
Here \uE035 is the ASCII code of F5 key.
Using executeScript() method:
The command is,