Is there any alternate way of refreshing a web page other than refresh() method in Selenium?

0 votes
Is there any alternate way of refreshing a web page other than refresh() method in Selenium?
Jul 22 in Selenium by Parineeti
68 views

1 answer to this question.

0 votes

HI Parineeti, to refresh a webpage, we either make use of Ctrl+f5 or Ctrl+R while using keyboard actions. Now we can imitate same keyboard action using ActionChains() method. ActionChains() method allows you to perform multiple keyboard actions in single command. Following lines of code explains how to use it:

import time
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
driver.get("https://www.google.com/")

time.sleep(5)

print("Before refresh")

ActionChains(driver) 
    .key_down(Keys.CONTROL)
    .send_keys(Keys.F5)
    .key_up(Keys.CONTROL)
    .perform()

print("After refresh")

sleep(5)
driver.quit()
answered Jul 23 by Anvi
• 13,840 points

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,090 points
799 views
0 votes
1 answer
0 votes
1 answer

What is the role of TestNG & JUnit frameworks in Selenium?

Well TestNG and JUnit are test frameworks ...READ MORE

answered Apr 18, 2018 in Selenium by king_kenny
• 3,650 points
306 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
1,039 views
0 votes
1 answer
0 votes
1 answer