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 23, 2019 in Selenium by Parineeti
2,164 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, 2019 by Anvi
• 14,150 points

Related Questions In Selenium

+1 vote
1 answer
0 votes
1 answer
0 votes
0 answers
0 votes
2 answers

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,500 points
12,576 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
8,558 views
0 votes
2 answers

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

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

answered Sep 4, 2020 in Selenium by Sri
• 3,190 points
2,472 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,910 points
6,603 views
0 votes
2 answers

Is there any way to get the text of a web element using Selenium Webdriver?

use gettext() in java : string lableText = ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
8,121 views
0 votes
1 answer

Why there is a need of GeckoDriver to launch Firefox in Selenium?

Hello Sunaina, Gecko driver is required to ...READ MORE

answered Jul 5, 2019 in Selenium by Anvi
• 14,150 points
601 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP