Explore Courses Blog Tutorials Interview Questions
0 votes
in DevOps and Agile by (19.7k points)

I just want to refresh an already opened web page with Selenium.

It always opens a new browser window.

Can anyone tell how it can be corrected?

from selenium import webdriver

import urllib

import urllib2

driver = webdriver.Firefox()


1 Answer

0 votes
by (62.9k points)

I would suggest binding the driver element search to the tag body and use the refresh command of the browser.

In OSX for example

driver.find_element_by_tag_name('body').send_keys(Keys.COMMAND + 'r')

Update: The following code, very similar to your one, works fine for me.

driver = webdriver.Firefox() driver.get(response.url) #tested in combination with scrapy time.sleep(3) driver.refresh()

If you are interested to learn Selenium on a much deeper level and want to become a professional in the testing domain, check out Intellipaat’s Selenium 3.0 certification

Browse Categories